Skip to content
Browse files

Fetch runtime deps on install, unless they exist.

Runtime deps are published with Yeti to the npm registry.
They are not available when installing from latest.yeti.cx
or a GitHub tarball. Install the runtime dependencies only
when they are not available.
  • Loading branch information...
1 parent c2a6f81 commit e3be31dc1542e9baa86286362a46f68adf946908 @reid reid committed Feb 28, 2013
Showing with 41 additions and 30 deletions.
  1. +1 −8 Jakefile.js
  2. +38 −22 scripts/fetch_deps.js
  3. +2 −0 scripts/postinstall.js
View
9 Jakefile.js
@@ -179,14 +179,7 @@ task("maintainer-clean", function () {
desc("Fetch external dependencies");
task("dep", function () {
jake.mkdirP('dep/dev');
- spawn(process.argv[0], ["./scripts/fetch_deps.js"], complete);
-}, {
- async: true
-});
-
-desc("Print history");
-task("history", function () {
- spawn(process.argv[0], ["./scripts/postinstall.js"], complete);
+ spawn(process.argv[0], ["./scripts/fetch_deps.js", "--dev"], complete);
}, {
async: true
});
View
60 scripts/fetch_deps.js
@@ -35,15 +35,16 @@ function log() {
}
var options = {
+ "dev": false,
"minify": false,
"debug": false
},
- argv = {};
+ argv = [];
function applyArgv() {
var k, v;
for (k in options) {
- v = argv.original.some(function (arg) {
+ v = argv.some(function (arg) {
return "--" + k === arg;
});
@@ -56,16 +57,19 @@ function applyArgv() {
}
}
+
if (process.env.npm_config_argv) {
try {
- argv = JSON.parse(process.env.npm_config_argv);
+ argv = JSON.parse(process.env.npm_config_argv).original;
} catch (ex) {
// Nothing.
}
+}
- if (argv.original) {
- applyArgv();
- }
+argv = argv.concat(process.argv.splice(1));
+
+if (argv.length) {
+ applyArgv();
}
function die(message) {
@@ -106,37 +110,49 @@ function saveURLToDep(sourceURL, filename, cb) {
}
function download(err) {
+ var scripts = [
+ [YUI_RUNTIME_URL, "yui-runtime.js"],
+ ["http://cdn.sockjs.org/sockjs-0.3.min.js", "sock.js"]
+ ];
+
if (err) {
die(err);
}
- [
- [YUI_TEST_URL, "dev/yui-test.js"],
- [QUNIT_JS_URL, "dev/qunit.js"],
- [QUNIT_CSS_URL, "dev/qunit.css"],
- [JASMINE_JS_URL, "dev/jasmine.js"],
- [JASMINE_JS_REPORTER_URL, "dev/jasmine-html.js"],
- [JASMINE_CSS_URL, "dev/jasmine.css"],
- [MOCHA_JS_URL, "dev/mocha.js"],
- [MOCHA_JS_ASSERTION_URL, "dev/expect.js"],
- [MOCHA_CSS_URL, "dev/mocha.css"],
- [DOJO_URL, "dev/dojo.js"],
- [DOJO_DOH_RUNNER_URL, "dev/dojo-doh-runner.js"],
- [YUI_RUNTIME_URL, "yui-runtime.js"],
- ["http://cdn.sockjs.org/sockjs-0.3.min.js", "sock.js"]
- ].forEach(function downloader(args) {
+ if (options.dev) {
+ scripts = scripts.concat([
+ [YUI_TEST_URL, "dev/yui-test.js"],
+ [QUNIT_JS_URL, "dev/qunit.js"],
+ [QUNIT_CSS_URL, "dev/qunit.css"],
+ [JASMINE_JS_URL, "dev/jasmine.js"],
+ [JASMINE_JS_REPORTER_URL, "dev/jasmine-html.js"],
+ [JASMINE_CSS_URL, "dev/jasmine.css"],
+ [MOCHA_JS_URL, "dev/mocha.js"],
+ [MOCHA_JS_ASSERTION_URL, "dev/expect.js"],
+ [MOCHA_CSS_URL, "dev/mocha.css"],
+ [DOJO_URL, "dev/dojo.js"],
+ [DOJO_DOH_RUNNER_URL, "dev/dojo-doh-runner.js"]
+ ]);
+ }
+
+ scripts.forEach(function downloader(args) {
+ if (!options.dev && fs.existsSync(path.join(depDir, args[1]))) {
+ return;
+ }
+
if (options.debug && args[0].indexOf("yui") !== -1) {
args[0] = args[0].replace(/[\.\-]min\.js/g, "-debug.js");
}
if (!options.minify) {
args[0] = args[0].replace(/[\.\-]min\.js/g, ".js");
}
+
saveURLToDep.apply(null, args);
});
}
-log("Downloading script dependencies...");
+log("Checking for script dependencies...");
fs.readdir(depDir, function (err) {
if (err) {
View
2 scripts/postinstall.js
@@ -12,6 +12,8 @@ function log() {
}
}
+require("./fetch_deps");
+
fs.readFile(path.join(__dirname, "..", "HISTORY.md"), "utf8", function (err, data) {
history = data.split("\n").slice(2, 20).join("\n");
process.on("exit", function () {

0 comments on commit e3be31d

Please sign in to comment.
Something went wrong with that request. Please try again.