quickbundle 0.0.0-next-386ba5d → 0.0.0-next-b797f75
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/dist/index.mjs +11 -12
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -19,7 +19,7 @@ import os from 'node:os';
|
|
|
19
19
|
import { gzipSize } from 'gzip-size';
|
|
20
20
|
|
|
21
21
|
var name = "quickbundle";
|
|
22
|
-
var version = "0.0.0-next-
|
|
22
|
+
var version = "0.0.0-next-b797f75";
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Resolve a relative path from the Quickbundle node modules directory.
|
|
@@ -68,21 +68,24 @@ const writeFile = async (filePath, content)=>{
|
|
|
68
68
|
};
|
|
69
69
|
const download = async (url, filePath)=>{
|
|
70
70
|
await createDirectory(dirname(filePath));
|
|
71
|
-
const { body } = await fetch(url);
|
|
71
|
+
const { body, ok, status, statusText } = await fetch(url);
|
|
72
|
+
if (!ok) {
|
|
73
|
+
throw new Error(`An error ocurred while downloading \`${url}\`. Received \`${status}\` status code with the following message \`${statusText}\`.`);
|
|
74
|
+
}
|
|
72
75
|
if (!body) {
|
|
73
|
-
throw new Error(`Empty body while
|
|
76
|
+
throw new Error(`Empty body received while downloading \`${url}\`.`);
|
|
74
77
|
}
|
|
75
|
-
|
|
78
|
+
await finished(Readable.fromWeb(body).pipe(createWriteStream(filePath)));
|
|
76
79
|
};
|
|
77
80
|
const unzip = async (input, output)=>{
|
|
78
|
-
const {
|
|
81
|
+
const { targetedArchivePath } = input;
|
|
79
82
|
const { directoryPath } = output;
|
|
80
83
|
await decompress(input.path, directoryPath, {
|
|
81
84
|
filter (file) {
|
|
82
|
-
return file.path ===
|
|
85
|
+
return file.path === targetedArchivePath;
|
|
83
86
|
}
|
|
84
87
|
});
|
|
85
|
-
await rename(join(directoryPath,
|
|
88
|
+
await rename(join(directoryPath, targetedArchivePath), join(directoryPath, output.filename));
|
|
86
89
|
};
|
|
87
90
|
const createCommand = (program, input)=>{
|
|
88
91
|
return program.command(input).option({
|
|
@@ -427,13 +430,9 @@ const createCompileCommand = (program)=>{
|
|
|
427
430
|
const osType = getOsType(matchedRuntimeParts.os);
|
|
428
431
|
const extension = osType === "windows" ? "zip" : "tar.gz";
|
|
429
432
|
await download(`https://nodejs.org/download/release/${matchedRuntimeParts.version}/${targetInput}.${extension}`, TEMPORARY_DOWNLOAD_PATH);
|
|
430
|
-
console.log(TEMPORARY_DOWNLOAD_PATH, {
|
|
431
|
-
directoryPath: dirname(TEMPORARY_RUNTIME_PATH),
|
|
432
|
-
filename: basename(TEMPORARY_RUNTIME_PATH)
|
|
433
|
-
});
|
|
434
433
|
await unzip({
|
|
435
434
|
path: TEMPORARY_DOWNLOAD_PATH,
|
|
436
|
-
|
|
435
|
+
targetedArchivePath: osType === "windows" ? join(targetInput, "node.exe") : join(targetInput, "bin", "node")
|
|
437
436
|
}, {
|
|
438
437
|
directoryPath: dirname(TEMPORARY_RUNTIME_PATH),
|
|
439
438
|
filename: basename(TEMPORARY_RUNTIME_PATH)
|