cargo-cp-artifact
Advanced tools
Comparing version 0.1.6 to 0.1.7
#!/usr/bin/env node | ||
"use strict"; | ||
const run = require("..") | ||
const run = require(".."); | ||
run(process.argv.slice(2), process.env); |
{ | ||
"name": "cargo-cp-artifact", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "Copies compiler artifacts emitted by rustc by parsing Cargo metadata", | ||
@@ -18,3 +18,3 @@ "main": "src/index.js", | ||
"type": "git", | ||
"url": "git+https://github.com/neon-bindings/cargo-cp-artifact.git" | ||
"url": "git+https://github.com/neon-bindings/neon.git" | ||
}, | ||
@@ -29,8 +29,8 @@ "keywords": [ | ||
"bugs": { | ||
"url": "https://github.com/neon-bindings/cargo-cp-artifact/issues" | ||
"url": "https://github.com/neon-bindings/neon/issues" | ||
}, | ||
"homepage": "https://github.com/neon-bindings/cargo-cp-artifact#readme", | ||
"homepage": "https://github.com/neon-bindings/neon/tree/main/pkgs/cargo-cp-artifact", | ||
"devDependencies": { | ||
"mocha": "^8.3.0" | ||
"mocha": "^10.0.0" | ||
} | ||
} |
@@ -11,4 +11,4 @@ "use strict"; | ||
"--", | ||
"cargo build --message-format=json-render-diagnostics" | ||
].join(" ") | ||
"cargo build --message-format=json-render-diagnostics", | ||
].join(" "), | ||
].join("\n"); | ||
@@ -18,5 +18,11 @@ | ||
switch (artifactType) { | ||
case "b": case "bin": return "bin"; | ||
case "c": case "cdylib": return "cdylib"; | ||
case "d": case "dylib": return "dylib"; | ||
case "b": | ||
case "bin": | ||
return "bin"; | ||
case "c": | ||
case "cdylib": | ||
return "cdylib"; | ||
case "d": | ||
case "dylib": | ||
return "dylib"; | ||
default: | ||
@@ -34,6 +40,8 @@ } | ||
if (!env.hasOwnProperty(NPM_ENV)) { | ||
throw new ParseError([ | ||
`Could not find the \`${NPM_ENV}\` environment variable.`, | ||
"Expected to be executed from an `npm` command." | ||
].join(" ")); | ||
throw new ParseError( | ||
[ | ||
`Could not find the \`${NPM_ENV}\` environment variable.`, | ||
"Expected to be executed from an `npm` command.", | ||
].join(" ") | ||
); | ||
} | ||
@@ -89,3 +97,6 @@ | ||
if (token === "--artifact" || (token.length <= 3 && token.startsWith("-a"))) { | ||
if ( | ||
token === "--artifact" || | ||
(token.length <= 3 && token.startsWith("-a")) | ||
) { | ||
const artifactType = getArtifactType(token); | ||
@@ -120,6 +131,6 @@ const crateName = getNext(); | ||
cmd, | ||
args: tokens | ||
} | ||
args: tokens, | ||
}; | ||
} | ||
module.exports = { ParseError, getArtifactName, parse }; |
"use strict"; | ||
const { spawn } = require("child_process"); | ||
const { promises: { copyFile, mkdir, stat } } = require("fs"); | ||
const { dirname } = require("path"); | ||
const { | ||
promises: { copyFile, mkdir, stat, unlink }, | ||
} = require("fs"); | ||
const { dirname, extname } = require("path"); | ||
const readline = require("readline"); | ||
@@ -15,3 +17,3 @@ | ||
const cp = spawn(options.cmd, options.args, { | ||
stdio: ["inherit", "pipe", "inherit"] | ||
stdio: ["inherit", "pipe", "inherit"], | ||
}); | ||
@@ -88,11 +90,12 @@ | ||
Promise | ||
.all(outputFiles.map(outputFile => copyArtifact(filename, outputFile))) | ||
.then(() => { | ||
copied[key] = true; | ||
}) | ||
.catch((err) => { | ||
process.exitCode = 1; | ||
console.error(err); | ||
}); | ||
Promise.all( | ||
outputFiles.map((outputFile) => copyArtifact(filename, outputFile)) | ||
) | ||
.then(() => { | ||
copied[key] = true; | ||
}) | ||
.catch((err) => { | ||
process.exitCode = 1; | ||
console.error(err); | ||
}); | ||
}); | ||
@@ -124,2 +127,20 @@ } | ||
// Apple Silicon (M1, etc.) requires shared libraries to be signed. However, | ||
// the macOS code signing cache isn't cleared when overwriting a file. | ||
// Deleting the file before copying works around the issue. | ||
// | ||
// Unfortunately, this workaround is incomplete because the file must be | ||
// deleted from the location it is loaded. If further steps in the user's | ||
// build process copy or move the file in place, the code signing cache | ||
// will not be cleared. | ||
// | ||
// https://github.com/neon-bindings/neon/issues/911 | ||
if (extname(outputFile) === ".node") { | ||
try { | ||
await unlink(outputFile); | ||
} catch (_e) { | ||
// Ignore errors; the file might not exist | ||
} | ||
} | ||
await copyFile(filename, outputFile); | ||
@@ -126,0 +147,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11794
240