From be0bce89c1015c3c4bb3a86adcc97abf3f056071 Mon Sep 17 00:00:00 2001 From: James Hamlin Date: Sun, 2 Feb 2014 23:31:08 -0800 Subject: [PATCH 1/3] Maintain file modes when copying a directory. A package may depend on some files in its dependencies being executable, so builder ought to respect the modes of source files when copying into a bundle. --- tools/builder.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/builder.js b/tools/builder.js index f8209d0121..970bacbe68 100644 --- a/tools/builder.js +++ b/tools/builder.js @@ -345,7 +345,8 @@ _.extend(Builder.prototype, { var thisAbsFrom = path.resolve(absFrom, item); var thisRelTo = path.join(relTo, item); - var isDir = fs.statSync(thisAbsFrom).isDirectory(); + var fileStatus = fs.statSync(thisAbsFrom); + var isDir = fileStatus.isDirectory(); var itemForMatch = item; if (isDir) itemForMatch += '/'; @@ -362,7 +363,8 @@ _.extend(Builder.prototype, { // XXX avoid reading whole file into memory var data = fs.readFileSync(thisAbsFrom); - fs.writeFileSync(path.resolve(self.buildPath, thisRelTo), data); + fs.writeFileSync(path.resolve(self.buildPath, thisRelTo), data, + { mode: fileStatus.mode }); self.usedAsFile[thisRelTo] = true; }); }; From ea793cb9064543842eb7be5457bc8e3813b0d5e4 Mon Sep 17 00:00:00 2001 From: David Glasser Date: Fri, 14 Feb 2014 00:17:08 -0800 Subject: [PATCH 2/3] Test for #1808 --- tools/tests/apps/npmtest/.meteor/.gitignore | 1 + tools/tests/apps/npmtest/.meteor/packages | 7 ++++ tools/tests/apps/npmtest/.meteor/release | 1 + .../apps/npmtest/packages/npm-test/npmtest.js | 2 ++ .../apps/npmtest/packages/npm-test/package.js | 5 +++ tools/tests/npm.js | 36 +++++++++++++++++++ 6 files changed, 52 insertions(+) create mode 100644 tools/tests/apps/npmtest/.meteor/.gitignore create mode 100644 tools/tests/apps/npmtest/.meteor/packages create mode 100644 tools/tests/apps/npmtest/.meteor/release create mode 100644 tools/tests/apps/npmtest/packages/npm-test/npmtest.js create mode 100644 tools/tests/apps/npmtest/packages/npm-test/package.js create mode 100644 tools/tests/npm.js diff --git a/tools/tests/apps/npmtest/.meteor/.gitignore b/tools/tests/apps/npmtest/.meteor/.gitignore new file mode 100644 index 0000000000..4083037423 --- /dev/null +++ b/tools/tests/apps/npmtest/.meteor/.gitignore @@ -0,0 +1 @@ +local diff --git a/tools/tests/apps/npmtest/.meteor/packages b/tools/tests/apps/npmtest/.meteor/packages new file mode 100644 index 0000000000..51e2314a4c --- /dev/null +++ b/tools/tests/apps/npmtest/.meteor/packages @@ -0,0 +1,7 @@ +# Meteor packages used by this project, one per line. +# +# 'meteor add' and 'meteor remove' will edit this file for you, +# but you can also edit it by hand. + +standard-app-packages +npm-test diff --git a/tools/tests/apps/npmtest/.meteor/release b/tools/tests/apps/npmtest/.meteor/release new file mode 100644 index 0000000000..621e94f0ec --- /dev/null +++ b/tools/tests/apps/npmtest/.meteor/release @@ -0,0 +1 @@ +none diff --git a/tools/tests/apps/npmtest/packages/npm-test/npmtest.js b/tools/tests/apps/npmtest/packages/npm-test/npmtest.js new file mode 100644 index 0000000000..a1bf97a82e --- /dev/null +++ b/tools/tests/apps/npmtest/packages/npm-test/npmtest.js @@ -0,0 +1,2 @@ +// This will execute a shell script, print its output, and process.exit(0). +Npm.require('meteor-test-executable').doIt(); diff --git a/tools/tests/apps/npmtest/packages/npm-test/package.js b/tools/tests/apps/npmtest/packages/npm-test/package.js new file mode 100644 index 0000000000..38dd3027d7 --- /dev/null +++ b/tools/tests/apps/npmtest/packages/npm-test/package.js @@ -0,0 +1,5 @@ +Npm.depends({"meteor-test-executable": "0.0.1"}); + +Package.on_use(function (api) { + api.add_files("npmtest.js", "server"); +}); diff --git a/tools/tests/npm.js b/tools/tests/npm.js new file mode 100644 index 0000000000..f9998a6c53 --- /dev/null +++ b/tools/tests/npm.js @@ -0,0 +1,36 @@ +var selftest = require('../selftest.js'); +var Sandbox = selftest.Sandbox; +var utils = require('../utils.js'); +var net = require('net'); +var Future = require('fibers/future'); +var _ = require('underscore'); +var files = require('../files.js'); + +var MONGO_LISTENING = + { stdout: " [initandlisten] waiting for connections on port" }; + +selftest.define("npm", ["net"], function () { + var s = new Sandbox({ fakeMongo: true }); + var run; + + s.createApp("npmtestapp", "npmtest"); + s.cd("npmtestapp"); + + // Ensure that we don't lose the executable bits of npm modules. + // Regression test for https://github.com/meteor/meteor/pull/1808 + // Before this fix, the module would work on the first execution but not on a + // subsequent one. + _.times(2, function (i) { + run = s.run("--once", "--raw-logs"); + run.tellMongo(MONGO_LISTENING); + if (i === 0) { + run.waitSecs(2); + run.read( + "npm-test: updating npm dependencies -- meteor-test-executable...\n"); + } + run.waitSecs(15); + run.read("null; From shell script\n"); + run.expectEnd(); + run.expectExit(0); + }); +}); From d4328d89b9d66997949844390a4da5cf230b7ccf Mon Sep 17 00:00:00 2001 From: David Glasser Date: Fri, 14 Feb 2014 00:20:12 -0800 Subject: [PATCH 3/3] history update for #1808 --- History.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/History.md b/History.md index 075d434af8..beaf66ac22 100644 --- a/History.md +++ b/History.md @@ -55,6 +55,8 @@ * Meteor accounts logins (or anything else using the `localstorage` package) no longer persist in IE7. +* Don't lose permissions (eg, executable bit) on npm files. #1808 + ## v0.7.0.1