forked from jupyterlab/jupyterlab
/
create-test-package.ts
37 lines (35 loc) · 1.29 KB
/
create-test-package.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
/*-----------------------------------------------------------------------------
| Copyright (c) Jupyter Development Team.
| Distributed under the terms of the Modified BSD License.
|----------------------------------------------------------------------------*/
import * as fs from 'fs-extra';
import * as path from 'path';
import * as utils from './utils';
if (require.main === module) {
// Make sure we have required command line arguments.
if (process.argv.length !== 3) {
let msg = '** Must supply a source package name\n';
process.stderr.write(msg);
process.exit(1);
}
let name = process.argv[2];
let pkgPath = path.resolve(path.join('.', 'packages', name));
if (!fs.existsSync(pkgPath)) {
console.error('Package does not exist: ', name);
process.exit(1);
}
let dest = path.resolve(`./tests/test-${name}`);
if (fs.existsSync(dest)) {
console.error('Test package already exists:', dest);
process.exit(1);
}
fs.copySync(path.resolve(path.join(__dirname, '..', 'test-template')), dest);
let jsonPath = path.join(dest, 'package.json');
let data = utils.readJSONFile(jsonPath);
if (name.indexOf('@jupyterlab/') === -1) {
name = '@jupyterlab/test-' + name;
}
data.name = name;
utils.writePackageData(jsonPath, data);
fs.ensureDir(path.join(dest, 'src'));
}