-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
develop.ts
56 lines (49 loc) · 1.45 KB
/
develop.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
51
52
53
54
55
56
/* -----------------------------------------------------------------------------
| Copyright (c) Jupyter Development Team.
| Distributed under the terms of the Modified BSD License.
|----------------------------------------------------------------------------*/
import commander from 'commander';
import fs from 'fs-extra';
import path from 'path';
import process from 'process';
import { run } from '@jupyterlab/buildutils';
commander
.description('Setup the repository for develop mode')
.option('--overwrite', 'Force linking the notebook schemas')
.option('--source', 'The path to the notebook package')
.action((options: any) => {
const { overwrite } = options;
const prefix = run(
'python -c "import sys; print(sys.prefix)"',
{
stdio: 'pipe',
},
true
);
const source = path.resolve(options.source ?? process.cwd());
const sourceDir = path.join(
source,
'notebook',
'schemas',
'@jupyter-notebook'
);
const destDir = path.join(
prefix,
'share',
'jupyter',
'lab',
'schemas',
'@jupyter-notebook'
);
if (overwrite) {
try {
fs.removeSync(destDir);
console.log('Removed previous destination:', destDir);
} catch (e) {
console.info('Skip unlink', destDir);
}
}
console.log('Symlinking:', sourceDir, destDir);
fs.symlinkSync(sourceDir, destDir, 'dir');
});
commander.parse(process.argv);