-
Notifications
You must be signed in to change notification settings - Fork 27.4k
chore(npm): use require.resolve when possible to avoid hard coded mod… #15071
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ module.exports = { | |
var reporters = grunt.option('reporters'); | ||
var noColor = grunt.option('no-colors'); | ||
var port = grunt.option('port'); | ||
var p = spawn('node', ['node_modules/karma/bin/karma', 'start', config, | ||
var p = spawn('node', [require.resolve('karma/bin/karma'), 'start', config, | ||
singleRun ? '--single-run=true' : '', | ||
reporters ? '--reporters=' + reporters : '', | ||
browsers ? '--browsers=' + browsers : '', | ||
|
@@ -38,7 +38,7 @@ module.exports = { | |
done(); | ||
return; | ||
} | ||
var p = spawn('node', ['node_modules/protractor/bin/webdriver-manager', 'update']); | ||
var p = spawn('node', [require.resolve('protractor/bin/webdriver-manager'), 'update']); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True. So simply There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That would only resolve what's exported, not the binary. Have you tried specifying the binary as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't want to complicate the PR actually, but if this is future-proof then let's do it |
||
p.stdout.pipe(process.stdout); | ||
p.stderr.pipe(process.stderr); | ||
p.on('exit', function(code) { | ||
|
@@ -54,7 +54,7 @@ module.exports = { | |
var sauceBuild = grunt.option('capabilities.build'); | ||
var browser = grunt.option('browser'); | ||
var specs = grunt.option('specs'); | ||
var args = ['node_modules/protractor/bin/protractor', config]; | ||
var args = [require.resolve('protractor/bin/protractor'), config]; | ||
if (sauceUser) args.push('--sauceUser=' + sauceUser); | ||
if (sauceKey) args.push('--sauceKey=' + sauceKey); | ||
if (tunnelIdentifier) args.push('--capabilities.tunnel-identifier=' + tunnelIdentifier); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to add
node
here, otherwise Windows wouldn't execute the commandThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather not depend on the internal
gulp
package structure. How about creating the npm scriptgulp
in package.json:and then
npm run gulp -- --gulpfile docs/gulpfile.js
should work everywhere.