@@ -4,28 +4,29 @@ import * as expect from 'expect.js';
4
4
5
5
process . chdir ( __dirname ) ;
6
6
7
- let cross = path . resolve ( __dirname , '../source/index.js' ) ;
7
+ const cross = path . resolve ( __dirname , '../source/index.js' ) ;
8
+ const { platform } = process
8
9
9
10
describe ( 'Loader' , ( ) => {
10
11
11
12
it ( 'should fail if it\'s invoked with an invalid script' , ( ) => {
12
13
13
14
const stdout = execSync ( `node ${ cross } invalid` )
14
- expect ( stdout . toString ( ) ) . to . match ( / s c r i p t : ' i n v a l i d ' n o t f o u n d \. / )
15
+ expect ( stdout . toString ( ) ) . to . match ( new RegExp ( ` script: 'invalid' not found for the current platform: ${ platform } ` ) )
15
16
16
17
} )
17
18
18
19
it ( 'should run the correct script on the right OS' , ( ) => {
19
20
20
21
const stdout = execSync ( `node ${ cross } first` )
21
- expect ( stdout . toString ( ) ) . to . match ( new RegExp ( `hello from ${ process . platform } ` ) )
22
+ expect ( stdout . toString ( ) ) . to . match ( new RegExp ( `hello from ${ platform } ` ) )
22
23
23
24
} )
24
25
25
26
it ( 'should fail silently if script for an specific OS is not found' , ( ) => {
26
27
27
28
const stdout = execSync ( `node ${ cross } second` )
28
- expect ( stdout . toString ( ) ) . to . be . empty ( ) ;
29
+ expect ( stdout . toString ( ) . trim ( ) ) . to . match ( new RegExp ( `script: 'second' not found for the current platform: ${ platform } ` ) ) ;
29
30
30
31
} )
31
32
@@ -58,7 +59,7 @@ describe('Loader', () => {
58
59
} )
59
60
60
61
child . on ( 'exit' , code => {
61
- expect ( output . trim ( ) ) . to . match ( new RegExp ( `hello from ${ process . platform } ` ) )
62
+ expect ( output . trim ( ) ) . to . match ( new RegExp ( `hello from ${ platform } ` ) )
62
63
expect ( code ) . to . be ( 0 )
63
64
done ( )
64
65
} )
@@ -68,7 +69,7 @@ describe('Loader', () => {
68
69
it ( 'should run scripts defined in cross-os attributes' , ( ) => {
69
70
70
71
const stdout = execSync ( `node ${ cross } fifth` )
71
- expect ( stdout . toString ( ) ) . to . match ( new RegExp ( `hello from cross-os ${ process . platform } ` ) )
72
+ expect ( stdout . toString ( ) ) . to . match ( new RegExp ( `hello from cross-os ${ platform } ` ) )
72
73
73
74
} )
74
75
@@ -83,7 +84,7 @@ describe('Loader', () => {
83
84
} )
84
85
85
86
child . on ( 'exit' , code => {
86
- expect ( output . trim ( ) ) . to . match ( new RegExp ( `hello from cross-os ${ process . platform } ` ) )
87
+ expect ( output . trim ( ) ) . to . match ( new RegExp ( `hello from cross-os ${ platform } ` ) )
87
88
expect ( code ) . to . be ( 0 )
88
89
done ( )
89
90
} )
@@ -101,7 +102,7 @@ describe('Loader', () => {
101
102
} )
102
103
103
104
child . on ( 'exit' , code => {
104
- expect ( output . trim ( ) ) . to . match ( new RegExp ( `hello from ${ process . platform } ` ) )
105
+ expect ( output . trim ( ) ) . to . match ( new RegExp ( `hello from ${ platform } ` ) )
105
106
expect ( code ) . to . be ( 0 )
106
107
done ( )
107
108
} )
0 commit comments