UNPKG

1.84 kBJavaScriptView Raw
1"use strict";
2/*-----------------------------------------------------------------------------
3| Copyright (c) Jupyter Development Team.
4| Distributed under the terms of the Modified BSD License.
5|----------------------------------------------------------------------------*/
6var __importStar = (this && this.__importStar) || function (mod) {
7 if (mod && mod.__esModule) return mod;
8 var result = {};
9 if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
10 result["default"] = mod;
11 return result;
12};
13Object.defineProperty(exports, "__esModule", { value: true });
14const fs = __importStar(require("fs-extra"));
15const path = __importStar(require("path"));
16const utils = __importStar(require("./utils"));
17if (require.main === module) {
18 // Make sure we have required command line arguments.
19 if (process.argv.length !== 3) {
20 let msg = '** Must supply a source package name\n';
21 process.stderr.write(msg);
22 process.exit(1);
23 }
24 let name = process.argv[2];
25 let pkgPath = path.resolve(path.join('.', 'packages', name));
26 if (!fs.existsSync(pkgPath)) {
27 console.error('Package does not exist: ', name);
28 process.exit(1);
29 }
30 let dest = path.resolve(`./tests/test-${name}`);
31 if (fs.existsSync(dest)) {
32 console.error('Test package already exists:', dest);
33 process.exit(1);
34 }
35 fs.copySync(path.resolve(path.join(__dirname, '..', 'test-template')), dest);
36 let jsonPath = path.join(dest, 'package.json');
37 let data = utils.readJSONFile(jsonPath);
38 if (name.indexOf('@jupyterlab/') === -1) {
39 name = '@jupyterlab/test-' + name;
40 }
41 data.name = name;
42 utils.writePackageData(jsonPath, data);
43 fs.ensureDirSync(path.join(dest, 'src'));
44}
45//# sourceMappingURL=create-test-package.js.map
\No newline at end of file