diff --git a/npm-packages/meteor-installer/config.js b/npm-packages/meteor-installer/config.js index d6f57191b9..b04cdd59ed 100644 --- a/npm-packages/meteor-installer/config.js +++ b/npm-packages/meteor-installer/config.js @@ -2,13 +2,15 @@ const path = require('path'); const os = require('os'); const METEOR_LATEST_VERSION = '2.3.5'; - -const localAppData = process.env.LOCALAPPDATA; -const isWindows = () => os.platform === 'win32'; -const rootPath = isWindows() ? localAppData : os.homedir(); +const sudoUser = process.env.SUDO_USER || ''; function isRoot() { return process.getuid && process.getuid() === 0; } +const localAppData = process.env.LOCALAPPDATA; +const isWindows = () => os.platform() === 'win32'; +const rootPath = isWindows() + ? localAppData + : `${isRoot() ? `/home/${sudoUser}` : os.homedir()}`; if (isWindows() && !localAppData) { throw new Error('LOCALAPPDATA env var is not set.'); @@ -21,6 +23,8 @@ module.exports = { extractPath: rootPath, meteorPath, release: process.env.INSTALL_METEOR_VERSION || METEOR_LATEST_VERSION, + rootPath, + sudoUser, startedPath: path.resolve(rootPath, '.meteor-install-started.txt'), isWindows, isRoot, diff --git a/npm-packages/meteor-installer/extract.js b/npm-packages/meteor-installer/extract.js index 37ba5252d5..cf40639478 100644 --- a/npm-packages/meteor-installer/extract.js +++ b/npm-packages/meteor-installer/extract.js @@ -48,7 +48,13 @@ function createSymlinks(symlinks, baseDir) { } function extractWithNativeTar (tarPath, destination, onProgress) { - child_process.execSync(`tar -xzf "${tarPath}" -C "${destination}" -o`) + child_process.execSync(`tar -xf "${tarPath}" --checkpoint-action=ttyout="#%u: %T \r" -C "${destination}"`, { + cwd: process.cwd(), + env: process.env, + stdio: [process.stdin, process.stdout, process.stderr], + encoding: 'utf-8' + }) + } function extractWithTar (tarPath, destination, onProgress) { @@ -70,6 +76,7 @@ function extractWithTar (tarPath, destination, onProgress) { return new Promise((resolve, reject) => { tar.x({ file: tarPath, + preservePaths: true, cwd: destination, filter(path, entry) { if (entry.type === 'SymbolicLink') { diff --git a/npm-packages/meteor-installer/install.js b/npm-packages/meteor-installer/install.js index 692e31a6d0..afe59690bf 100644 --- a/npm-packages/meteor-installer/install.js +++ b/npm-packages/meteor-installer/install.js @@ -14,6 +14,9 @@ const { startedPath, extractPath, isWindows, + isRoot, + rootPath, + sudoUser, } = require('./config.js'); const { uninstall } = require('./uninstall'); const { @@ -21,7 +24,6 @@ const { extractWith7Zip, extractWithNativeTar, } = require('./extract.js'); -const { isRoot } = require('./config'); process.on('unhandledRejection', err => { throw err; @@ -105,7 +107,7 @@ function download() { dl.on('progress', ({ progress }) => { downloadProgress.update(progress); }); - dl.on('end', () => { + dl.on('end', async () => { downloadProgress.update(100); downloadProgress.stop(); const end = Date.now(); @@ -123,23 +125,13 @@ function download() { fs.writeFileSync(startedPath, 'Meteor install started'); console.log('=> Extracting the tarball, this may take some time'); - const decompressProgress = new cliProgress.SingleBar( - { - format: 'Decompressing |{bar}| {percentage}%', - clearOnComplete: true, - }, - cliProgress.Presets.shades_classic - ); - decompressProgress.start(100, 0); const extractStart = Date.now(); - extractWithNativeTar(path.resolve(tempPath, tarGzName), extractPath); + await extractWithNativeTar(path.resolve(tempPath, tarGzName), extractPath); const extractEnd = Date.now(); - decompressProgress.update(100); - decompressProgress.stop(); console.log( `=> Meteor extracted in ${(extractEnd - extractStart) / 1000}s` ); - setup(); + await setup(); }); dl.start(); @@ -222,15 +214,14 @@ async function setupExecPath() { ? '.zshrc' : '.bashrc'; await fsPromises.appendFile( - `${os.homedir()}/${bashrcFile}`, - `export PATH=$PATH:${meteorPath}\n` + `${rootPath}/${bashrcFile}`, + `export PATH=${meteorPath}:$PATH\n` ); if (!isRoot()) { return; } // if we identified sudo is being used, we need to change the ownership of the meteorpath folder - const user = process.env.SUDO_USER; - child_process.execSync(`chown -R ${user} "${meteorPath}"`); + child_process.execSync(`chown -R ${sudoUser} "${meteorPath}"`); } function showGettingStarted() { diff --git a/npm-packages/meteor-installer/package.json b/npm-packages/meteor-installer/package.json index ab79388afa..7baaf17332 100644 --- a/npm-packages/meteor-installer/package.json +++ b/npm-packages/meteor-installer/package.json @@ -1,6 +1,6 @@ { "name": "meteor", - "version": "2.3.5", + "version": "2.3.6-beta4", "description": "Install Meteor on Windows", "main": "install.js", "scripts": {