Skip to content

Commit c429f3f

Browse files
committed
fix warning message not displaying if script not found
1 parent e4f55cb commit c429f3f

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cross-os",
3-
"version": "1.1.1",
3+
"version": "1.1.2",
44
"description": "Allow to add OS-specific scripts in your package.json!",
55
"main": "source/index.js",
66
"bin": "source/index.js",

source/index.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import * as path from 'path';
44
import { exec, spawn } from 'child_process';
55

6+
const { platform } = process;
7+
68
/**
79
* Grab package.json
810
*/
@@ -23,19 +25,21 @@ const pipeline = new Promise(resolve => {
2325
}
2426

2527
try {
26-
return Promise.resolve(config[property][script][process.platform]);
28+
return Promise.resolve({ command: config[property][script][platform], script })
2729
} catch (e) {
2830
throw script
2931
}
3032

31-
}).then((command: string) => {
33+
}).then(({ command, script }) => {
3234

3335
/**
3436
* Execute the script
3537
*/
3638
if (command)
37-
spawn(command, [], { stdio: 'inherit', shell: true })
39+
return spawn(command, [], { stdio: 'inherit', shell: true })
40+
41+
throw script
3842

3943
}).catch(error => {
40-
console.log(`script: '${error}' not found.\n`)
44+
console.log('\x1b[33m', `script: '${error}' not found for the current platform: ${platform}\n`, '\x1b[39m')
4145
})

0 commit comments

Comments
 (0)