Skip to content

Commit

Permalink
fix: rewrite deploy script as esm
Browse files Browse the repository at this point in the history
  • Loading branch information
wessberg committed Jan 23, 2023
1 parent 1949fbc commit d2488b7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,24 @@ if (needsNode || !hasAcceptableNodeVersion) {
: "Node.js is missing on the host machine. Installing"
);

if (!hasAcceptableNodeVersion) {
await ssh.execCommand(`sudo apt remove node && sudo apt autoremove`);
}
await ssh.execCommand(`cd ~`);
await ssh.execCommand(`curl -sL https://deb.nodesource.com/setup_${PREFERRED_NODE_VERSION} -o nodesource_setup.sh`);
await ssh.execCommand(`sudo bash nodesource_setup.sh`);
await ssh.execCommand(`sudo apt install nodejs -y`);
await ssh.execCommand(`rm nodesource_setup.sh`);
console.log("Node.js successfully installed!");

// Re-check the installed Node version and ensure that it is in fact the intended one
const nodeVersionNow = (await ssh.execCommand("node -v")).stdout.slice(1);
if (!satisfies(nodeVersionNow, PREFERRED_NODE_VERSION)) {
throw new ReferenceError(`Node v${PREFERRED_NODE_VERSION} could not be installed.`);
} else {
console.log("Node.js successfully installed!");
}


} else {
console.log("Node.js is already supported");
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
"node.parentelement": "1.0.2",
"perfnow": "0.2.0",
"performance-now": "2.1.0",
"pm2": "5.2.0",
"pm2": "5.2.2",
"polyfill-library": "3.108.0",
"proxy-polyfill": "0.3.2",
"regenerator-runtime": "0.13.11",
Expand Down

0 comments on commit d2488b7

Please sign in to comment.