test-bdk-cli 0.1.15 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/create.js +1 -1
- package/dist/commands/test.js +11 -4
- package/package.json +1 -1
package/dist/commands/create.js
CHANGED
|
@@ -55,7 +55,7 @@ function registerCreate(program) {
|
|
|
55
55
|
}
|
|
56
56
|
appDirectories = collected.length ? collected : ['.'];
|
|
57
57
|
}
|
|
58
|
-
const template = opts.template || '
|
|
58
|
+
const template = opts.template || 'default';
|
|
59
59
|
const basePath = path_1.default.resolve(opts.path || '.');
|
|
60
60
|
// flatten nested array if commander wrapped variadic into single array
|
|
61
61
|
if (Array.isArray(appDirectories) && appDirectories.length === 1 && Array.isArray(appDirectories[0])) {
|
package/dist/commands/test.js
CHANGED
|
@@ -10,10 +10,17 @@ function registerTest(program) {
|
|
|
10
10
|
.option('--watch', 're-run tests on file changes', false)
|
|
11
11
|
.option('--coverage', 'generate coverage report', false)
|
|
12
12
|
.action((sourceArg, opts) => {
|
|
13
|
-
const
|
|
13
|
+
const path = require('path');
|
|
14
|
+
const fs = require('fs');
|
|
15
|
+
const cwd = path.resolve(process.cwd(), sourceArg || '.');
|
|
16
|
+
// Check if package.json exists and has test script
|
|
17
|
+
const pkgPath = path.join(cwd, 'package.json');
|
|
14
18
|
const hasPkg = (() => {
|
|
15
19
|
try {
|
|
16
|
-
|
|
20
|
+
if (!fs.existsSync(pkgPath)) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
const p = require(pkgPath);
|
|
17
24
|
return !!p.scripts && (p.scripts.test || p.scripts['test:watch']);
|
|
18
25
|
}
|
|
19
26
|
catch (e) {
|
|
@@ -28,7 +35,7 @@ function registerTest(program) {
|
|
|
28
35
|
// prefer npm run test -- --watch if available
|
|
29
36
|
try {
|
|
30
37
|
console.log('Running tests in watch mode...');
|
|
31
|
-
const child = (0, child_process_1.spawn)('npm', ['run', 'test', '--', '--watch'], { stdio: 'inherit', cwd:
|
|
38
|
+
const child = (0, child_process_1.spawn)('npm', ['run', 'test', '--', '--watch'], { stdio: 'inherit', cwd: cwd, shell: true });
|
|
32
39
|
child.on('exit', (code) => process.exit(code || 0));
|
|
33
40
|
}
|
|
34
41
|
catch (e) {
|
|
@@ -44,7 +51,7 @@ function registerTest(program) {
|
|
|
44
51
|
args.push('--', '--coverage');
|
|
45
52
|
}
|
|
46
53
|
console.log('Running tests...');
|
|
47
|
-
(0, child_process_1.execSync)('npm ' + args.join(' '), { stdio: 'inherit', cwd:
|
|
54
|
+
(0, child_process_1.execSync)('npm ' + args.join(' '), { stdio: 'inherit', cwd: cwd });
|
|
48
55
|
}
|
|
49
56
|
catch (e) {
|
|
50
57
|
console.error('Tests failed.');
|