mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
npm support: comment improvements and simple npm-shrinkwrap.json files
This commit is contained in:
committed by
David Glasser
parent
5baac15fc0
commit
cda70deb6b
@@ -37,18 +37,17 @@ var meteorNpm = module.exports = {
|
||||
// we already nave a .npm directory. update it:
|
||||
// - create new tmp directory for the new contents of .npm
|
||||
// - copy npm-shrinkwrap.json from .npm to the temp directory
|
||||
// - construct package.json, which is needed for `npm install`
|
||||
// - in temp directory, construct package.json, which is needed for `npm install`
|
||||
// - call `npm install`, which reads from npm-shrinkwrap.json
|
||||
// - call `npm install foo@version` for any package that needs to be updated
|
||||
// - call `npm install name@version` for any package that needs to be updated
|
||||
// - call `npm prune` to remove any unused packages from node_modules
|
||||
// - call `npm shrinkwrap` to update npm-shrinkwrap.json
|
||||
// - copy the temporary directory back to .npm
|
||||
self._updateExistingNpmDirectory(packageName, tmpPackageNpmDir, packageNpmDir, npmDependencies);
|
||||
} else {
|
||||
// create fresh .npm directory:
|
||||
// create a temporary directory for the new contents of .npm:
|
||||
// - create .gitignore
|
||||
// - install npm modules
|
||||
// - construct package.json, without which `npm shrinkwrap` generates a different looking npm-shrinkwrap.json
|
||||
// - call `npm shrinkwrap` to create npm-shrinkwrap.json
|
||||
// - copy the temporary directory to .npm
|
||||
self._createFreshNpmDirectory(packageName, tmpPackageNpmDir, packageNpmDir, npmDependencies);
|
||||
@@ -61,6 +60,8 @@ var meteorNpm = module.exports = {
|
||||
|
||||
_updateExistingNpmDirectory: function(packageName, tmpPackageNpmDir, packageNpmDir, npmDependencies) {
|
||||
var self = this;
|
||||
|
||||
// sanity check on contents of .npm directory
|
||||
if (!fs.statSync(packageNpmDir).isDirectory())
|
||||
throw new Error("Corrupted .npm directory -- should be a directory: " + packageNpmDir);
|
||||
if (!fs.existsSync(path.join(packageNpmDir, 'npm-shrinkwrap.json')))
|
||||
@@ -87,7 +88,7 @@ var meteorNpm = module.exports = {
|
||||
// `npm install`
|
||||
self._installFromShrinkwrap(tmpPackageNpmDir);
|
||||
|
||||
// install modules that need updating
|
||||
// `npm install name@version` for modules that need updating
|
||||
_.each(npmDependencies, function(version, name) {
|
||||
if (installedDependencies[name] !== version) {
|
||||
self._installNpmModule(name, version, tmpPackageNpmDir);
|
||||
@@ -154,9 +155,9 @@ var meteorNpm = module.exports = {
|
||||
_finalizeTmpPackageDirAndRename: function(tmpPackageNpmDir, packageNpmDir) {
|
||||
var self = this;
|
||||
|
||||
self._shrinkwrap(tmpPackageNpmDir);
|
||||
if (fs.existsSync(path.join(tmpPackageNpmDir, 'package.json')))
|
||||
fs.unlinkSync(path.join(tmpPackageNpmDir, 'package.json'));
|
||||
self._shrinkwrap(tmpPackageNpmDir);
|
||||
|
||||
if (fs.existsSync(packageNpmDir)) {
|
||||
var oldPackageNpmDir = packageNpmDir + '-old-' + self._randomToken();;
|
||||
|
||||
@@ -39,9 +39,7 @@ var _assertCorrectPackageNpmDir = function(deps) {
|
||||
assert.equal(
|
||||
fs.readFileSync(path.join(testPackageDir, ".npm", "npm-shrinkwrap.json"), 'utf8'),
|
||||
JSON.stringify({
|
||||
name: "packages-for-meteor-smartpackage-test-package",
|
||||
version: "0.0.0",
|
||||
dependencies: expectedMeteorNpmShrinkwrapDependencies}, null, /*indentation, the way npm uses it*/2) + '\n');
|
||||
dependencies: expectedMeteorNpmShrinkwrapDependencies}, null, /*indentation, the way npm does it*/2) + '\n');
|
||||
|
||||
// verify the contents of the `node_modules` dir
|
||||
var nodeModulesDir = path.join(testPackageDir, ".npm", "node_modules");
|
||||
|
||||
Reference in New Issue
Block a user