forked from meteor/meteor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace setup.sh with npm-rebuild.js, and run it on npm install.
Implements meteor#6537 (comment) The setup.sh script was only sometimes written previously, so no existing deployment logic should rely on it existing. On the other hand, all apps built by `meteor build` require running `npm install` in the programs/server/ directory, so the install hook I added to programs/server/package.json will ensure npm-rebuild.js is invoked reliably. Using a pure Node script means this code will work just as well on Windows as on Linux or Darwin, though Linux is by far the most common deployment platform for Meteor apps. TODO Remember to rebuild the dev bundle before the next release!
- Loading branch information
Ben Newman
committed
Apr 7, 2016
1 parent
2dd511f
commit c18c1f5
Showing
3 changed files
with
59 additions
and
11 deletions.
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
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,47 @@ | ||
var path = require("path"); | ||
var spawn = require("child_process").spawn; | ||
|
||
try { | ||
// This JSON file gets written in meteor/tools/isobuild/bundler.js. | ||
var rebuilds = require("./npm-rebuilds.json"); | ||
} catch (e) { | ||
if (e.code !== "MODULE_NOT_FOUND") { | ||
throw e; | ||
} | ||
// If npm-rebuilds.json was not written, assume there is nothing that | ||
// needs to be rebuilt. | ||
} | ||
|
||
// Make sure the npm finds this exact version of node in its $PATH. | ||
var PATH = path.dirname(process.execPath) + ":" + process.env.PATH; | ||
var env = Object.create(process.env, { | ||
PATH: { value: PATH } | ||
}); | ||
|
||
function rebuild(i) { | ||
var dir = rebuilds && rebuilds[i]; | ||
|
||
if (! dir) { | ||
// Print Node/V8/etc. versions for diagnostic purposes. | ||
spawn("npm", ["version", "--json"], { | ||
stdio: "inherit", | ||
env: env | ||
}); | ||
|
||
return; | ||
} | ||
|
||
spawn("npm", ["rebuild"], { | ||
cwd: path.join(__dirname, dir), | ||
stdio: "inherit", | ||
env: env | ||
}).on("exit", function (code) { | ||
if (code !== 0) { | ||
process.exit(code); | ||
} else { | ||
rebuild(i + 1); | ||
} | ||
}); | ||
} | ||
|
||
rebuild(0); |