-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(npm): update to npm 3.10.2 (#1250)
The npm task from our current ember-cli install uses npm 2.x.x, which was causing issues with some of the dependencies. This PR copies over all files needed for the npm-install task but uses a local 3.10.2 npm version instead. Fix #1186 (main issue) Fix #1191 Fix #1201 Fix #1209 Fix #1207 Fix #1248
- Loading branch information
1 parent
5183e1d
commit 6f0ebfb
Showing
5 changed files
with
116 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use strict'; | ||
|
||
// Runs `npm install` in cwd | ||
|
||
var NpmTask = require('./npm-task'); | ||
|
||
module.exports = NpmTask.extend({ | ||
command: 'install', | ||
startProgressMessage: 'Installing packages for tooling via npm', | ||
completionMessage: 'Installed packages for tooling via npm.' | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/*eslint-disable no-console */ | ||
'use strict'; | ||
|
||
// Runs `npm install` in cwd | ||
|
||
var chalk = require('chalk'); | ||
var Task = require('ember-cli/lib/models/task'); | ||
var npm = require('../utilities/npm'); | ||
|
||
module.exports = Task.extend({ | ||
// The command to run: can be 'install' or 'uninstall' | ||
command: '', | ||
// Message to send to ui.startProgress | ||
startProgressMessage: '', | ||
// Message to send to ui.writeLine on completion | ||
completionMessage: '', | ||
|
||
init: function() { | ||
this.npm = this.npm || require('npm'); | ||
}, | ||
// Options: Boolean verbose | ||
run: function(options) { | ||
this.ui.startProgress(chalk.green(this.startProgressMessage), chalk.green('.')); | ||
|
||
var npmOptions = { | ||
loglevel: options.verbose ? 'verbose' : 'error', | ||
progress: false, | ||
logstream: this.ui.outputStream, | ||
color: 'always', | ||
// by default, do install peoples optional deps | ||
'optional': 'optional' in options ? options.optional : true, | ||
'save-dev': !!options['save-dev'], | ||
'save-exact': !!options['save-exact'] | ||
}; | ||
|
||
var packages = options.packages || []; | ||
|
||
// npm otherwise is otherwise noisy, already submitted PR for npm to fix | ||
// misplaced console.log | ||
this.disableLogger(); | ||
|
||
return npm(this.command, packages, npmOptions, this.npm). | ||
finally(this.finally.bind(this)). | ||
then(this.announceCompletion.bind(this)); | ||
}, | ||
|
||
announceCompletion: function() { | ||
this.ui.writeLine(chalk.green(this.completionMessage)); | ||
}, | ||
|
||
finally: function() { | ||
this.ui.stopProgress(); | ||
this.restoreLogger(); | ||
}, | ||
|
||
disableLogger: function() { | ||
this.oldLog = console.log; | ||
console.log = function() {}; | ||
}, | ||
|
||
restoreLogger: function() { | ||
console.log = this.oldLog; // Hack, see above | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use strict'; | ||
|
||
var Promise = require('ember-cli/lib/ext/promise'); | ||
|
||
// | ||
|
||
/** | ||
Runs the npm command `command` with the supplied args and load options. | ||
Please note that the loaded module appears to retain some state, so do not | ||
expect multiple invocations within the same process to work without quirks. | ||
This problem is likely fixable. | ||
@method npm | ||
@param {String} command The npm command to run. | ||
@param {Array} npmArgs The arguments passed to the npm command. | ||
@param {Array} options The options passed when loading npm. | ||
@param {Module} [npm] A reference to the npm module. | ||
*/ | ||
module.exports = function npm(command, npmArgs, options/*, npm*/) { | ||
var lib; | ||
if (arguments.length === 4) { | ||
lib = arguments[3]; | ||
} else { | ||
lib = require('npm'); | ||
} | ||
|
||
var load = Promise.denodeify(lib.load); | ||
|
||
return load(options) | ||
.then(function() { | ||
// if install is denodeified outside load.then(), | ||
// it throws "Call npm.load(config, cb) before using this command." | ||
var operation = Promise.denodeify(lib.commands[command]); | ||
|
||
return operation(npmArgs || []); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters