Skip to content

Commit 9b2756f

Browse files
committed
fixed script loading bug
1 parent dcc173b commit 9b2756f

File tree

3 files changed

+34
-28
lines changed

3 files changed

+34
-28
lines changed

scripts/mocha-istanbul-report.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
var cp = require('child_process');
3030
var fs = require('fs-extra');
31+
var path = require('path');
3132
var stripJsonComments = require('strip-json-comments');
3233

3334
var testEntry = 'test';
@@ -74,21 +75,22 @@ try
7475
{
7576
if (fs.statSync('./.npmscriptrc.js').isFile())
7677
{
77-
configInfo = require('./.npmscriptrc.js');
78+
configInfo = require(path.resolve('./.npmscriptrc.js'));
7879
}
7980
}
80-
catch (err) { /* nop */ }
81-
82-
// Attempt to load `.npmscriptrc` and strip comments.
83-
/* istanbul ignore next */
84-
try
81+
catch (err)
8582
{
86-
if (fs.statSync('./.npmscriptrc').isFile())
83+
// Attempt to load `.npmscriptrc` and strip comments.
84+
/* istanbul ignore next */
85+
try
8786
{
88-
configInfo = JSON.parse(stripJsonComments(fs.readFileSync('./.npmscriptrc', 'utf-8')));
87+
if (fs.statSync('./.npmscriptrc').isFile())
88+
{
89+
configInfo = JSON.parse(stripJsonComments(fs.readFileSync('./.npmscriptrc', 'utf-8')));
90+
}
8991
}
92+
catch (err) { /* nop */ }
9093
}
91-
catch (err) { /* nop */ }
9294

9395
// Exit now if no configInfo object has been loaded.
9496
if (typeof configInfo !== 'object')

scripts/mocha-istanbul.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
var cp = require('child_process');
2626
var fs = require('fs-extra');
27+
var path = require('path');
2728
var stripJsonComments = require('strip-json-comments');
2829

2930
var testEntry = 'test';
@@ -70,21 +71,22 @@ try
7071
{
7172
if (fs.statSync('./.npmscriptrc.js').isFile())
7273
{
73-
configInfo = require('./.npmscriptrc.js');
74+
configInfo = require(path.resolve('./.npmscriptrc.js'));
7475
}
7576
}
76-
catch (err) { /* nop */ }
77-
78-
// Attempt to load `.npmscriptrc` and strip comments.
79-
/* istanbul ignore next */
80-
try
77+
catch (err)
8178
{
82-
if (fs.statSync('./.npmscriptrc').isFile())
79+
// Attempt to load `.npmscriptrc` and strip comments.
80+
/* istanbul ignore next */
81+
try
8382
{
84-
configInfo = JSON.parse(stripJsonComments(fs.readFileSync('./.npmscriptrc', 'utf-8')));
83+
if (fs.statSync('./.npmscriptrc').isFile())
84+
{
85+
configInfo = JSON.parse(stripJsonComments(fs.readFileSync('./.npmscriptrc', 'utf-8')));
86+
}
8587
}
88+
catch (err) { /* nop */ }
8689
}
87-
catch (err) { /* nop */ }
8890

8991
// Exit now if no configInfo object has been loaded.
9092
if (typeof configInfo !== 'object')

scripts/mocha.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
var cp = require('child_process');
1515
var fs = require('fs');
16+
var path = require('path');
1617
var stripJsonComments = require('strip-json-comments');
1718

1819
var testEntry = 'test';
@@ -45,21 +46,22 @@ try
4546
{
4647
if (fs.statSync('./.npmscriptrc.js').isFile())
4748
{
48-
configInfo = require('./.npmscriptrc.js');
49+
configInfo = require(path.resolve('./.npmscriptrc.js'));
4950
}
5051
}
51-
catch (err) { /* nop */ }
52-
53-
// Attempt to load `.npmscriptrc` and strip comments.
54-
/* istanbul ignore next */
55-
try
52+
catch (err)
5653
{
57-
if (fs.statSync('./.npmscriptrc').isFile())
54+
// Attempt to load `.npmscriptrc` and strip comments.
55+
/* istanbul ignore next */
56+
try
5857
{
59-
configInfo = JSON.parse(stripJsonComments(fs.readFileSync('./.npmscriptrc', 'utf-8')));
58+
if (fs.statSync('./.npmscriptrc').isFile())
59+
{
60+
configInfo = JSON.parse(stripJsonComments(fs.readFileSync('./.npmscriptrc', 'utf-8')));
61+
}
6062
}
63+
catch (err) { /* nop */ }
6164
}
62-
catch (err) { /* nop */ }
6365

6466
// Exit now if no configInfo object has been loaded.
6567
if (typeof configInfo !== 'object')
@@ -113,4 +115,4 @@ exec += ' ' + testConfig.mocha.source;
113115

114116
// Notify what command is being executed then execute it.
115117
process.stdout.write('Executing: ' + exec + '\n');
116-
cp.execSync(exec, { stdio: 'inherit' });
118+
cp.execSync(exec, { stdio: 'inherit' });

0 commit comments

Comments
 (0)