@wyrd-company/intentional 0.5.1 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/install.js +20 -3
- package/package.json +1 -1
package/install.js
CHANGED
|
@@ -242,6 +242,16 @@ async function install(options = {}) {
|
|
|
242
242
|
const packageMetadata = options.packageMetadata || require("./package.json");
|
|
243
243
|
const target = options.target || selectTarget();
|
|
244
244
|
const urls = releaseUrls(packageMetadata.version, target);
|
|
245
|
+
const environment = options.environment || process.env;
|
|
246
|
+
const releaseFiles = environment.INTENTIONAL_RELEASE_FILES;
|
|
247
|
+
if (releaseFiles === "") {
|
|
248
|
+
throw new Error("INTENTIONAL_RELEASE_FILES must name a directory");
|
|
249
|
+
}
|
|
250
|
+
// npm runs postinstall in the package directory and records the caller's directory in INIT_CWD.
|
|
251
|
+
const stagedDirectory =
|
|
252
|
+
releaseFiles && !path.isAbsolute(releaseFiles)
|
|
253
|
+
? path.resolve(environment.INIT_CWD || process.cwd(), releaseFiles)
|
|
254
|
+
: releaseFiles;
|
|
245
255
|
const temporaryDirectory = fs.mkdtempSync(path.join(os.tmpdir(), "intentional-install-"));
|
|
246
256
|
const checksumFile = path.join(temporaryDirectory, "SHA256SUMS");
|
|
247
257
|
const archive = path.join(temporaryDirectory, target.asset);
|
|
@@ -249,9 +259,16 @@ async function install(options = {}) {
|
|
|
249
259
|
const destination = path.join(packageRoot, "bin", nativeName);
|
|
250
260
|
|
|
251
261
|
try {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
262
|
+
if (stagedDirectory === undefined) {
|
|
263
|
+
console.log(`intentional: downloading ${target.asset}`);
|
|
264
|
+
const fetch = options.download || download;
|
|
265
|
+
await fetch(urls.checksums, checksumFile);
|
|
266
|
+
await fetch(urls.archive, archive);
|
|
267
|
+
} else {
|
|
268
|
+
console.log(`intentional: reading staged ${target.asset}`);
|
|
269
|
+
await fs.promises.copyFile(path.join(stagedDirectory, "SHA256SUMS"), checksumFile);
|
|
270
|
+
await fs.promises.copyFile(path.join(stagedDirectory, target.asset), archive);
|
|
271
|
+
}
|
|
255
272
|
const expected = parseChecksum(fs.readFileSync(checksumFile, "utf8"), target.asset);
|
|
256
273
|
verifyChecksum(archive, expected);
|
|
257
274
|
(options.extractExecutable || extractExecutable)(archive, target, destination);
|