Skip to content

Commit

Permalink
fix(usage): Fix available scripts message on Windows (#15)
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
sudo-suhas authored and Kent C. Dodds committed Nov 8, 2017
1 parent 72eac4a commit e63d892
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/run-script.js
Expand Up @@ -8,7 +8,10 @@ if (script) {
} else {
const scriptsPath = path.join(__dirname, 'scripts/')
const scriptsAvailable = glob.sync(path.join(__dirname, 'scripts', '*'))
// `glob.sync` returns paths with unix style path separators even on Windows.
// So we normalize it before attempting to strip out the scripts path.
const scriptsAvailableMessage = scriptsAvailable
.map(path.normalize)
.map(s =>
s
.replace(scriptsPath, '')
Expand Down

0 comments on commit e63d892

Please sign in to comment.