4 # homepage: https://nodejs.org
5 # tagline: JavaScript V8 runtime
7 # Node.jsĀ® is a JavaScript runtime built on Chrome's V8 JavaScript engine
13 # node -e 'console.log("Hello, World!")'
17 # ### A Simple Web Server
22 # var http = require('http');
23 # var app = function (req, res) {
24 # res.end('Hello, World!');
26 # http.createServer(app).listen(8080, function () {
27 # console.info('Listening on', this.address());
41 # npm install --save express
49 # var express = require('express');
50 # var app = express();
52 # app.use('/', function (req, res, next) {
53 # res.end("Hello, World!");
56 # module.exports = app;</code></pre>
64 # var http = require('http');
65 # var app = require('./app.js');
67 # http.createServer(app).listen(8080, function () {
68 # console.info('Listening on', this.address());
80 pkg_get_current_version() {
81 # 'node --version' has output in this format:
83 # This trims it down to just the version number:
85 echo "$(node --version 2>/dev/null | sed 's:^v::')"
88 pkg_format_cmd_version() {
89 # 'node v12.8.0' is the canonical version format for node
91 echo "$pkg_cmd_name v$my_version"
94 pkg_link_new_version() {
95 # 'pkg_common_opt' will default to $HOME/.local/opt/node
96 # 'pkg_new_opt' will be the installed version, such as to $HOME/.local/opt/node-v12.8.0
97 rm -rf "$pkg_common_opt"
98 ln -s "$pkg_new_opt" "$pkg_common_opt"
102 # web_* are defined in webi/template.bash at https://github.com/webinstall/packages
104 # if selected version is installed, re-link it and quit
107 # will save to ~/Downloads/$WEBI_PKG_FILE by default
110 # supported formats (.xz, .tar.*, .zip) will be extracted to $WEBI_TMP
115 pushd "$WEBI_TMP" 2>&1 >/dev/null
117 # remove the versioned folder, just in case it's there with junk
118 rm -rf "$pkg_new_opt"
120 # rename the entire extracted folder to the new location
121 # (this will be "$HOME/.local/opt/node-v$WEBI_VERSION" by default)
122 mv ./"$pkg_cmd_name"* "$pkg_new_opt"
130 # web_path_add is defined in webi/template.bash at https://github.com/webinstall/packages
131 # Adds "$HOME/.local/opt/node/bin" to PATH
132 webi_path_add "$pkg_common_bin"
135 pkg_post_install_message() {
136 echo "Installed 'node' and 'npm'"