Skip to content

Commit e63d892

Browse files
sudo-suhasKent C. Dodds
authored andcommitted
fix(usage): Fix available scripts message on Windows (#15)
On Windows, the available scripts message includes file path as well. This happens because `glob.sync` returns paths with unix style separators and the `replace(scriptsPath, '')` fails. Fix the issue using `path.normalize`.
1 parent 72eac4a commit e63d892

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/run-script.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ if (script) {
88
} else {
99
const scriptsPath = path.join(__dirname, 'scripts/')
1010
const scriptsAvailable = glob.sync(path.join(__dirname, 'scripts', '*'))
11+
// `glob.sync` returns paths with unix style path separators even on Windows.
12+
// So we normalize it before attempting to strip out the scripts path.
1113
const scriptsAvailableMessage = scriptsAvailable
14+
.map(path.normalize)
1215
.map(s =>
1316
s
1417
.replace(scriptsPath, '')

0 commit comments

Comments
 (0)