forked from jupyterlab/jupyterlab
/
remove-dependency.ts
executable file
·50 lines (42 loc) · 1.36 KB
/
remove-dependency.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env node
/*-----------------------------------------------------------------------------
| Copyright (c) Jupyter Development Team.
| Distributed under the terms of the Modified BSD License.
|----------------------------------------------------------------------------*/
import * as path from 'path';
import * as utils from './utils';
// Make sure we have required command line arguments.
if (process.argv.length !== 3) {
let msg = '** Must supply a library name\n';
process.stderr.write(msg);
process.exit(1);
}
let name = process.argv[2];
// Handle the packages
utils.getLernaPaths().forEach(pkgPath => {
handlePackage(pkgPath);
});
handlePackage(path.resolve('.'));
/**
* Handle an individual package on the path - update the dependency.
*/
function handlePackage(packagePath: string): void {
// Read in the package.json.
packagePath = path.join(packagePath, 'package.json');
let data: any;
try {
data = utils.readJSONFile(packagePath);
} catch (e) {
console.log('Skipping package ' + packagePath);
return;
}
// Update dependencies as appropriate.
for (let dtype of ['dependencies', 'devDependencies']) {
let deps = data[dtype] || {};
delete deps[name];
}
// Write the file back to disk.
utils.writePackageData(packagePath, data);
}
// Update the core jupyterlab build dependencies.
utils.run('jlpm run integrity');