-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #571 from flowforge/fix-stack-installer
Fix stack installer
- Loading branch information
Showing
4 changed files
with
64 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
const { exec } = require('child_process') | ||
const { log, error } = require('console') | ||
const fs = require('fs') | ||
const path = require('path') | ||
|
||
const flowforgeHome = process.env.FLOWFORGE_HOME | ||
|
||
let vers = process.env.npm_config_vers | ||
if (!vers) { | ||
vers = process.argv[process.argv.length - 1] | ||
if (!vers) { | ||
throw new Error('command line arg vars is missing') | ||
} | ||
} | ||
|
||
if (!/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/.test(vers)) { | ||
throw new Error('version not valid semantic version') | ||
} | ||
|
||
const p = path.join('var', 'stacks', vers) | ||
if (flowforgeHome) { | ||
path.join(flowforgeHome, p) | ||
} | ||
fs.mkdirSync(p, { recursive: true }) | ||
|
||
log(`installing stack node-red@${vers}`) | ||
const npmCmd = `npm install --prefix ${p} node-red@${vers}` | ||
|
||
exec(npmCmd, (err, stdout, stderr) => { | ||
if (err) { | ||
error(err) | ||
} else { | ||
log(`installed stack node-red@${vers}`) | ||
} | ||
}) |