mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix the script
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
071ba8ac24
commit
ea603c734e
@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
import child_process from "child_process";
|
||||
import { ensureDir } from "fs-extra";
|
||||
import fsExtra from "fs-extra";
|
||||
import fetch from "node-fetch";
|
||||
import { platform } from "process";
|
||||
import { SemVer } from "semver";
|
||||
@ -12,12 +12,14 @@ import stream from "stream";
|
||||
import { promisify } from "util";
|
||||
import { extract } from "tar";
|
||||
|
||||
function canvasPrebuiltUrlBuilder(canvasVersion: SemVer, nodeVersion: string) {
|
||||
const { ensureDir, readJson } = fsExtra;
|
||||
|
||||
function canvasPrebuiltUrlBuilder(canvasVersion: string, nodeVersion: string) {
|
||||
const compiler = platform === "linux"
|
||||
? "glibc"
|
||||
: "unknown";
|
||||
|
||||
return `https://github.com/Automattic/node-canvas/releases/download/v${canvasVersion.format()}/canvas-v${canvasVersion.format()}-node-v${nodeVersion}-${platform}-${compiler}-x64.tar.gz`;
|
||||
return `https://github.com/Automattic/node-canvas/releases/download/v${canvasVersion}/canvas-v${canvasVersion}-node-v${nodeVersion}-${platform}-${compiler}-x64.tar.gz`;
|
||||
}
|
||||
|
||||
const exec = promisify(child_process.exec);
|
||||
@ -26,11 +28,8 @@ const pipeline = promisify(stream.pipeline);
|
||||
// This is done so that we can skip the scripts for only this package
|
||||
await exec("npm install canvas@2 --no-save --no-package-lock --ignore-scripts");
|
||||
|
||||
const { stdout } = await exec("npm list --depth=0 --json");
|
||||
const output = JSON.parse(stdout);
|
||||
|
||||
const nodeModuleVersion = process.versions.modules;
|
||||
const canvasVersion = new SemVer(output.dependencies["canvas"].version);
|
||||
const canvasVersion = (await readJson("./node_modules/canvas/package.json")).version as string;
|
||||
const canvasPrebuildUrl = canvasPrebuiltUrlBuilder(canvasVersion, nodeModuleVersion);
|
||||
|
||||
const canvasPrebuilt = await fetch(canvasPrebuildUrl);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user