Skip to content

Commit

Permalink
fix: Ensure prepared externals binaries are executable
Browse files Browse the repository at this point in the history
It's what npm ensures, hence npm-cross-link should also
  • Loading branch information
medikoo committed Jul 10, 2019
1 parent 3e905c1 commit 5fab6a4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
35 changes: 24 additions & 11 deletions lib/private/setup-dependency/install-external/prepare/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
"use strict";

const memoizee = require("memoizee")
, { resolve } = require("path")
, isDirectory = require("fs2/is-directory")
, mkdir = require("fs2/mkdir")
, rename = require("fs2/rename")
, rm = require("fs2/rm")
, tmpdir = require("os").tmpdir()
, log = require("log").get("npm-cross-link")
, cachePath = require("../../../cache").path
, getPackageJson = require("../../../../get-package-json")
, updatePackageJson = require("../../../update-package-json");
const memoizee = require("memoizee")
, { resolve } = require("path")
, isDirectory = require("fs2/is-directory")
, mkdir = require("fs2/mkdir")
, rename = require("fs2/rename")
, chmod = require("fs2/chmod")
, rm = require("fs2/rm")
, tmpdir = require("os").tmpdir()
, log = require("log").get("npm-cross-link")
, cachePath = require("../../../cache").path
, getPackageJson = require("../../../../get-package-json")
, updatePackageJson = require("../../../update-package-json")
, resolveBinariesDict = require("../resolve-binaries-dict");

const methods = [require("./sem-ver"), require("./git"), require("./other")];

Expand Down Expand Up @@ -38,6 +40,17 @@ module.exports = memoizee(
recursive: true,
force: true
});

if (process.plaftorm !== "win32") {
const binariesDict = resolveBinariesDict(packageTmpDir);
if (binariesDict) {
await Promise.all(
Object.values(binariesDict).map(path =>
chmod(resolve(packageTmpDir, path), 0o111, { append: true })
)
);
}
}
if (!versionCachePath) return packageTmpDir;

await rename(packageTmpDir, versionCachePath, { intermediate: true });
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"es5-ext": "^0.10.50",
"essentials": "^1.0.0",
"event-emitter": "^0.3.5",
"fs2": "^0.3.4",
"fs2": "^0.3.5",
"got": "^9.6.0",
"log": "^6.0.0",
"log-node": "^7.0.0",
Expand Down

0 comments on commit 5fab6a4

Please sign in to comment.