mirror of
https://github.com/koush/scrypted.git
synced 2026-09-17 17:20:39 +01:00
server: add hook for npm exec in non-node environment (electron)
This commit is contained in:
4
server/package-lock.json
generated
4
server/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@scrypted/server",
|
||||
"version": "0.7.46",
|
||||
"version": "0.7.47",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@scrypted/server",
|
||||
"version": "0.7.46",
|
||||
"version": "0.7.47",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@mapbox/node-pre-gyp": "^1.0.10",
|
||||
|
||||
@@ -9,6 +9,19 @@ import rimraf from "rimraf";
|
||||
import semver from 'semver';
|
||||
import { ensurePluginVolume } from "./plugin-volume";
|
||||
|
||||
export function defaultNpmExec(args: string[], options: child_process.SpawnOptions) {
|
||||
let npm = 'npm';
|
||||
if (os.platform() === 'win32')
|
||||
npm += '.cmd';
|
||||
const cp = child_process.spawn(npm, args, options);
|
||||
return cp;
|
||||
}
|
||||
|
||||
let npmExecFunction = defaultNpmExec;
|
||||
export function setNpmExecFunction(f: typeof npmExecFunction) {
|
||||
npmExecFunction = f;
|
||||
}
|
||||
|
||||
export function getPluginNodePath(name: string) {
|
||||
const pluginVolume = ensurePluginVolume(name);
|
||||
const nodeMajorVersion = semver.parse(process.version).major;
|
||||
@@ -56,10 +69,7 @@ export async function installOptionalDependencies(console: Console, packageJson:
|
||||
mkdirp.sync(nodePrefix);
|
||||
fs.writeFileSync(packageJsonPath, JSON.stringify(reduced));
|
||||
|
||||
let npm = 'npm';
|
||||
if (os.platform() === 'win32')
|
||||
npm += '.cmd';
|
||||
const cp = child_process.spawn(npm, ['--prefix', nodePrefix, 'install'], {
|
||||
const cp = npmExecFunction(['--prefix', nodePrefix, 'install'], {
|
||||
cwd: nodePrefix,
|
||||
stdio: 'inherit',
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user