From 2ec71affbddc24aeb2eae9fd520a95f7511e2940 Mon Sep 17 00:00:00 2001 From: Ed Solis Date: Thu, 12 Jan 2017 00:44:30 -0600 Subject: [PATCH 01/10] Rework profile.js to use shellInitScriptChooser() --- lib/setup/profile.js | 111 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 103 insertions(+), 8 deletions(-) diff --git a/lib/setup/profile.js b/lib/setup/profile.js index aed6980..a2cf328 100644 --- a/lib/setup/profile.js +++ b/lib/setup/profile.js @@ -65,6 +65,96 @@ var appendScript = function(name, options) { }); }; +/** + * Chooses the correct shell init script to insert avn initialization string to, + * based on the following criteria: + * 1. Append to the one that's present, if the other doesn't exist, + * 2. If both exist, append to the one that is sourced by the other, or + * 3. If both exist, but neither sources the other, + * append to .bashrc if platform is 'linux', + * or append to .bash_profile if platform is 'darwin' (i.e. macOS) + * + * @private + * @function setup.profile.~shellInitScriptChooser + * @return {Promise} + */ +var shellInitScriptChooser = function() { + var bashrcFile = path.join(process.env.HOME, '.bashrc'); + var bash_profileFile = path.join(process.env.HOME, '.bash_profile'); + var bashrcExists; + var bash_profileExists; + + // Check if .bashrc exists + var bashrcPromise = new Promise(function(resolve) { + fs.access(bashrcFile, function(err) { + bashrcExists = !err; + resolve(); + }); + }); + + // Check if .bash_profile exists + var bash_profilePromise = new Promise(function(resolve) { + fs.access(bash_profileFile, function(err) { + bash_profileExists = !err; + resolve(); + }); + }); + + var promise = Promise.all([bashrcPromise, bash_profilePromise]) + .then(function() { + if (bashrcExists ^ bash_profileExists) // ^ == bitwise XOR + return (bashrcExists && bashrcFile) || + (bash_profileExists && bash_profileFile); + + if (bashrcExists && bash_profileExists) { + var innerPromise = new Promise(function(resolve) { + fs.readFile(bash_profileFile, 'utf8', function(err, data) { + // RegExp to detect "~/.bashrc", + // "$HOME/.bashrc", or "/home/user/.bashrc" + var bashrcRe = new RegExp(' ?source +(\\\\\\n)? *(~\/.bashrc|' + + "\"?\\$HOME\/.bashrc\"?|[\'\"]?\/home\/\\w+\/.bashrc[\'\"]?)"); + + bashrcRe.test(data) ? resolve(bashrcFile) : resolve(); + }); + }) + .then(function(appendFile) { + if (appendFile) + return appendFile; + + var innerInnerPromise = new Promise(function(resolve) { + fs.readFile(bashrcFile, 'utf8', function(err, data) { + // RegExp to detect "~/.bash_profile", + // "$HOME/.bash_profile", or "/home/user/.bash_profile" + var bash_profileRe = new RegExp(' ?source +(\\\\\\n)? *' + + "(~\/.bash_profile|\"?\\$HOME\/.bash_profile\"?|" + + "[\'\"]?\/home\/\\w+\/.bash_profile[\'\"]?)"); + + bash_profileRe.test(data) ? resolve(bash_profileFile) : resolve(); + }); + }); + + return innerInnerPromise; + }) + .then(function(appendFile) { + if (appendFile) + return appendFile; + + // Neither .bashrc nor .bash_profile sources the other + var platformsToInitScript = { + linux: bashrcFile, + darwin: bash_profileFile + } + + return platformsToInitScript[process.platform]; + }); + + return innerPromise; + } + }); + + return promise; +}; + /** * Update `~/.bash_profile` and `.zshrc` shell profile files. * @@ -77,20 +167,23 @@ var appendScript = function(name, options) { module.exports.update = function() { var handled = false; var changed = false; + var appendFile; - var promise = Promise.map(['.bash_profile', '.zshrc'], function(name) { - return appendScript(name); + var promise = shellInitScriptChooser() + .then(function(initScript) { + appendFile = initScript; + return appendScript(appendFile); }) - .each(function(result) { + .then(function(result) { if (result) { handled = true; changed = changed || (result === 'change'); } - }); + }) - promise = promise.then(function() { + .then(function() { if (!handled) { - return appendScript('.bash_profile', { force: true }); + return appendScript(appendFile, { force: true }); } }) .then(function(result) { @@ -98,12 +191,14 @@ module.exports.update = function() { handled = true; changed = changed || (result === 'change'); } - }); + }) - return promise.then(function() { + .then(function() { if (changed) { console.log('%s: %s', chalk.bold.magenta('avn'), chalk.bold.cyan('restart your terminal to start using avn')); } }); + + return promise; }; From 62b514bad46fe7930a992f3371153ecdaf2cbcce Mon Sep 17 00:00:00 2001 From: Ed Solis Date: Thu, 12 Jan 2017 01:03:51 -0600 Subject: [PATCH 02/10] Fix code style errors --- lib/setup/profile.js | 50 +++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/lib/setup/profile.js b/lib/setup/profile.js index a2cf328..66eee3b 100644 --- a/lib/setup/profile.js +++ b/lib/setup/profile.js @@ -80,9 +80,9 @@ var appendScript = function(name, options) { */ var shellInitScriptChooser = function() { var bashrcFile = path.join(process.env.HOME, '.bashrc'); - var bash_profileFile = path.join(process.env.HOME, '.bash_profile'); + var bashProfileFile = path.join(process.env.HOME, '.bash_profile'); var bashrcExists; - var bash_profileExists; + var bashProfileExists; // Check if .bashrc exists var bashrcPromise = new Promise(function(resolve) { @@ -94,56 +94,68 @@ var shellInitScriptChooser = function() { // Check if .bash_profile exists var bash_profilePromise = new Promise(function(resolve) { - fs.access(bash_profileFile, function(err) { - bash_profileExists = !err; + fs.access(bashProfileFile, function(err) { + bashProfileExists = !err; resolve(); }); }); var promise = Promise.all([bashrcPromise, bash_profilePromise]) .then(function() { - if (bashrcExists ^ bash_profileExists) // ^ == bitwise XOR + if ((bashrcExists || bashProfileExists) && + !(bashrcExists && bashProfileExists)) { // ^ == bitwise XOR return (bashrcExists && bashrcFile) || - (bash_profileExists && bash_profileFile); + (bashProfileExists && bashProfileFile); + } - if (bashrcExists && bash_profileExists) { + if (bashrcExists && bashProfileExists) { var innerPromise = new Promise(function(resolve) { - fs.readFile(bash_profileFile, 'utf8', function(err, data) { + fs.readFile(bashProfileFile, 'utf8', function(err, data) { // RegExp to detect "~/.bashrc", // "$HOME/.bashrc", or "/home/user/.bashrc" var bashrcRe = new RegExp(' ?source +(\\\\\\n)? *(~\/.bashrc|' + - "\"?\\$HOME\/.bashrc\"?|[\'\"]?\/home\/\\w+\/.bashrc[\'\"]?)"); + '\"?\\$HOME\/.bashrc\"?|[\'\"]?\/home\/\\w+\/.bashrc[\'\"]?)'); - bashrcRe.test(data) ? resolve(bashrcFile) : resolve(); + if (bashrcRe.test(data)) { + resolve(bashrcFile); + } else { + resolve(); + } }); }) .then(function(appendFile) { - if (appendFile) + if (appendFile) { return appendFile; + } var innerInnerPromise = new Promise(function(resolve) { fs.readFile(bashrcFile, 'utf8', function(err, data) { // RegExp to detect "~/.bash_profile", // "$HOME/.bash_profile", or "/home/user/.bash_profile" - var bash_profileRe = new RegExp(' ?source +(\\\\\\n)? *' + - "(~\/.bash_profile|\"?\\$HOME\/.bash_profile\"?|" + - "[\'\"]?\/home\/\\w+\/.bash_profile[\'\"]?)"); - - bash_profileRe.test(data) ? resolve(bash_profileFile) : resolve(); + var bashProfileRe = new RegExp(' ?source +(\\\\\\n)? *' + + '(~\/.bash_profile|\"?\\$HOME\/.bash_profile\"?|' + + '[\'\"]?\/home\/\\w+\/.bash_profile[\'\"]?)'); + + if (bashProfileRe.test(data)) { + resolve(bashProfileFile); + } else { + resolve(); + } }); }); return innerInnerPromise; }) .then(function(appendFile) { - if (appendFile) + if (appendFile) { return appendFile; + } // Neither .bashrc nor .bash_profile sources the other var platformsToInitScript = { linux: bashrcFile, - darwin: bash_profileFile - } + darwin: bashProfileFile + }; return platformsToInitScript[process.platform]; }); From db567c4b8fbdd80ac9f26a0ac96aa6b6176ba59e Mon Sep 17 00:00:00 2001 From: Ed Solis Date: Thu, 12 Jan 2017 01:07:53 -0600 Subject: [PATCH 03/10] Fix camelcase --- lib/setup/profile.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/setup/profile.js b/lib/setup/profile.js index 66eee3b..7597549 100644 --- a/lib/setup/profile.js +++ b/lib/setup/profile.js @@ -93,14 +93,14 @@ var shellInitScriptChooser = function() { }); // Check if .bash_profile exists - var bash_profilePromise = new Promise(function(resolve) { + var bashProfilePromise = new Promise(function(resolve) { fs.access(bashProfileFile, function(err) { bashProfileExists = !err; resolve(); }); }); - var promise = Promise.all([bashrcPromise, bash_profilePromise]) + var promise = Promise.all([bashrcPromise, bashProfilePromise]) .then(function() { if ((bashrcExists || bashProfileExists) && !(bashrcExists && bashProfileExists)) { // ^ == bitwise XOR From a4df2f8e9d72b9f6b41c9634a33ceb2eb01744cb Mon Sep 17 00:00:00 2001 From: Ed Solis Date: Thu, 12 Jan 2017 01:11:47 -0600 Subject: [PATCH 04/10] Fix code style errors, again --- lib/setup/profile.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/setup/profile.js b/lib/setup/profile.js index 7597549..d87bdba 100644 --- a/lib/setup/profile.js +++ b/lib/setup/profile.js @@ -102,10 +102,10 @@ var shellInitScriptChooser = function() { var promise = Promise.all([bashrcPromise, bashProfilePromise]) .then(function() { - if ((bashrcExists || bashProfileExists) && - !(bashrcExists && bashProfileExists)) { // ^ == bitwise XOR - return (bashrcExists && bashrcFile) || - (bashProfileExists && bashProfileFile); + if ((bashrcExists || bashProfileExists) && + !(bashrcExists && bashProfileExists)) { // ^ == bitwise XOR + return (bashrcExists && bashrcFile) || + (bashProfileExists && bashProfileFile); } if (bashrcExists && bashProfileExists) { @@ -118,7 +118,8 @@ var shellInitScriptChooser = function() { if (bashrcRe.test(data)) { resolve(bashrcFile); - } else { + } + else { resolve(); } }); @@ -138,7 +139,8 @@ var shellInitScriptChooser = function() { if (bashProfileRe.test(data)) { resolve(bashProfileFile); - } else { + } + else { resolve(); } }); @@ -154,7 +156,7 @@ var shellInitScriptChooser = function() { // Neither .bashrc nor .bash_profile sources the other var platformsToInitScript = { linux: bashrcFile, - darwin: bashProfileFile + darwin: bashProfileFile, }; return platformsToInitScript[process.platform]; From 3a12d2b0f865618f66c9ad1f81e7157564224165 Mon Sep 17 00:00:00 2001 From: Ed Solis Date: Tue, 17 Jan 2017 19:42:47 -0600 Subject: [PATCH 05/10] Filename bugfixes; Provide for neither exists, and .zshrc w/ .bash_profile --- lib/setup/profile.js | 70 ++++++++++++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 25 deletions(-) diff --git a/lib/setup/profile.js b/lib/setup/profile.js index d87bdba..1f6a6b4 100644 --- a/lib/setup/profile.js +++ b/lib/setup/profile.js @@ -8,6 +8,9 @@ var util = require('util'); var chalk = require('chalk'); var isNoEntry = require('../util/codes').isNoEntry; +var bashProfileFileName = '.bash_profile'; +var bashrcFileName = '.bashrc'; + /** * Generate the string to be included in the shell init script. * @@ -79,34 +82,27 @@ var appendScript = function(name, options) { * @return {Promise} */ var shellInitScriptChooser = function() { - var bashrcFile = path.join(process.env.HOME, '.bashrc'); - var bashProfileFile = path.join(process.env.HOME, '.bash_profile'); - var bashrcExists; - var bashProfileExists; + var bashrcFile = path.join(process.env.HOME, bashrcFileName); + var bashProfileFile = path.join(process.env.HOME, bashProfileFileName); // Check if .bashrc exists var bashrcPromise = new Promise(function(resolve) { fs.access(bashrcFile, function(err) { - bashrcExists = !err; - resolve(); + resolve(!err); }); }); // Check if .bash_profile exists var bashProfilePromise = new Promise(function(resolve) { fs.access(bashProfileFile, function(err) { - bashProfileExists = !err; - resolve(); + resolve(!err); }); }); var promise = Promise.all([bashrcPromise, bashProfilePromise]) - .then(function() { - if ((bashrcExists || bashProfileExists) && - !(bashrcExists && bashProfileExists)) { // ^ == bitwise XOR - return (bashrcExists && bashrcFile) || - (bashProfileExists && bashProfileFile); - } + .then(function(fileExistenceValues) { + var bashrcExists = fileExistenceValues[0]; + var bashProfileExists = fileExistenceValues[1]; if (bashrcExists && bashProfileExists) { var innerPromise = new Promise(function(resolve) { @@ -117,7 +113,7 @@ var shellInitScriptChooser = function() { '\"?\\$HOME\/.bashrc\"?|[\'\"]?\/home\/\\w+\/.bashrc[\'\"]?)'); if (bashrcRe.test(data)) { - resolve(bashrcFile); + resolve(bashrcFileName); } else { resolve(); @@ -138,7 +134,7 @@ var shellInitScriptChooser = function() { '[\'\"]?\/home\/\\w+\/.bash_profile[\'\"]?)'); if (bashProfileRe.test(data)) { - resolve(bashProfileFile); + resolve(bashProfileFileName); } else { resolve(); @@ -155,8 +151,8 @@ var shellInitScriptChooser = function() { // Neither .bashrc nor .bash_profile sources the other var platformsToInitScript = { - linux: bashrcFile, - darwin: bashProfileFile, + linux: bashrcFileName, + darwin: bashProfileFileName, }; return platformsToInitScript[process.platform]; @@ -164,13 +160,22 @@ var shellInitScriptChooser = function() { return innerPromise; } + + else if (bashrcExists || bashProfileExists) { // XOR file existence + return (bashrcExists && bashrcFileName) || + (bashProfileExists && bashProfileFileName); + } + + else { // Default if neither exists + return bashProfileFileName; + } }); return promise; }; /** - * Update `~/.bash_profile` and `.zshrc` shell profile files. + * Update `~/.bash_profile` and `.zshrc`, or `.bashrc` shell profile files. * * Adds the necessary commands to load `avn.sh` when a new shell is launched. * @@ -186,12 +191,27 @@ module.exports.update = function() { var promise = shellInitScriptChooser() .then(function(initScript) { appendFile = initScript; - return appendScript(appendFile); - }) - .then(function(result) { - if (result) { - handled = true; - changed = changed || (result === 'change'); + + if (appendFile === bashProfileFileName) { + Promise.map([bashProfileFileName, '.zshrc'], function(name) { + return appendScript(name); + }) + .each(function(result) { + if (result) { + handled = true; + changed = changed || (result === 'change'); + } + }); + } + + else if (appendFile === bashrcFileName) { + return appendScript(bashrcFileName) + .then(function(result) { + if (result) { + handled = true; + changed = changed || (result === 'change'); + } + }); } }) From 3e4fe81bbc0bc57f2d5112a268554807b7987142 Mon Sep 17 00:00:00 2001 From: Ed Solis Date: Mon, 23 Jan 2017 16:25:22 -0600 Subject: [PATCH 06/10] Treat mz/fs as Promisified --- lib/setup/profile.js | 100 +++++++++++++++++++------------------------ 1 file changed, 44 insertions(+), 56 deletions(-) diff --git a/lib/setup/profile.js b/lib/setup/profile.js index 1f6a6b4..41bc98f 100644 --- a/lib/setup/profile.js +++ b/lib/setup/profile.js @@ -84,66 +84,58 @@ var appendScript = function(name, options) { var shellInitScriptChooser = function() { var bashrcFile = path.join(process.env.HOME, bashrcFileName); var bashProfileFile = path.join(process.env.HOME, bashProfileFileName); - - // Check if .bashrc exists - var bashrcPromise = new Promise(function(resolve) { - fs.access(bashrcFile, function(err) { - resolve(!err); - }); - }); + var bashProfileNotExist; + var bashrcNotExist; // Check if .bash_profile exists - var bashProfilePromise = new Promise(function(resolve) { - fs.access(bashProfileFile, function(err) { - resolve(!err); + return fs.access(bash_profileFile) + .catch(function(err) { + bashProfileNotExist = err; + }) + + // Check if .bashrc exists + .then(function() { + return fs.access(bashrcFile) + .catch(function(err) { + bashrcNotExist = err; }); - }); + }) - var promise = Promise.all([bashrcPromise, bashProfilePromise]) - .then(function(fileExistenceValues) { - var bashrcExists = fileExistenceValues[0]; - var bashProfileExists = fileExistenceValues[1]; - - if (bashrcExists && bashProfileExists) { - var innerPromise = new Promise(function(resolve) { - fs.readFile(bashProfileFile, 'utf8', function(err, data) { - // RegExp to detect "~/.bashrc", - // "$HOME/.bashrc", or "/home/user/.bashrc" - var bashrcRe = new RegExp(' ?source +(\\\\\\n)? *(~\/.bashrc|' + - '\"?\\$HOME\/.bashrc\"?|[\'\"]?\/home\/\\w+\/.bashrc[\'\"]?)'); - - if (bashrcRe.test(data)) { - resolve(bashrcFileName); - } - else { - resolve(); - } - }); + .then(function() { + if (!bashProfileNotExist && !bashrcNotExist) { + return fs.readFile(bashProfileFile, 'utf8') + .then(function(data) { + // RegExp to detect "~/.bashrc", + // "$HOME/.bashrc", or "/home/user/.bashrc" + var bashrcRe = new RegExp(' ?source +(\\\\\\n)? *(~\/.bashrc|' + + '\"?\\$HOME\/.bashrc\"?|[\'\"]?\/home\/\\w+\/.bashrc[\'\"]?)'); + + if (bashrcRe.test(data)) { + return bashrcFileName; + } + return; }) + .then(function(appendFile) { if (appendFile) { return appendFile; } - var innerInnerPromise = new Promise(function(resolve) { - fs.readFile(bashrcFile, 'utf8', function(err, data) { - // RegExp to detect "~/.bash_profile", - // "$HOME/.bash_profile", or "/home/user/.bash_profile" - var bashProfileRe = new RegExp(' ?source +(\\\\\\n)? *' + - '(~\/.bash_profile|\"?\\$HOME\/.bash_profile\"?|' + - '[\'\"]?\/home\/\\w+\/.bash_profile[\'\"]?)'); - - if (bashProfileRe.test(data)) { - resolve(bashProfileFileName); - } - else { - resolve(); - } - }); - }); + return fs.readFile(bashrcFile, 'utf8') + .then(function(data) { + // RegExp to detect "~/.bash_profile", + // "$HOME/.bash_profile", or "/home/user/.bash_profile" + var bash_profileRe = new RegExp(' ?source +(\\\\\\n)? *' + + '(~\/.bash_profile|\"?\\$HOME\/.bash_profile\"?|' + + '[\'\"]?\/home\/\\w+\/.bash_profile[\'\"]?)'); - return innerInnerPromise; + if(bash_profileRe.test(data)) { + return bashProfileFileName; + } + return; + }); }) + .then(function(appendFile) { if (appendFile) { return appendFile; @@ -155,23 +147,19 @@ var shellInitScriptChooser = function() { darwin: bashProfileFileName, }; - return platformsToInitScript[process.platform]; + return platformsToInitScript[process.platform] || bashProfileFileName; }); - - return innerPromise; } - else if (bashrcExists || bashProfileExists) { // XOR file existence - return (bashrcExists && bashrcFileName) || - (bashProfileExists && bashProfileFileName); + else if (!bashProfileNotExist || !bashrcNotExist) { // XOR file existence + return (bashProfileNotExist && bashrcFileName) || + (bashrcNotExist && bashProfileFileName); } else { // Default if neither exists return bashProfileFileName; } }); - - return promise; }; /** From 5d5c01db609f1388288e74d72f8960d219f3f43b Mon Sep 17 00:00:00 2001 From: Ed Solis Date: Mon, 23 Jan 2017 16:33:40 -0600 Subject: [PATCH 07/10] Fix style: camelcase --- lib/setup/profile.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/setup/profile.js b/lib/setup/profile.js index 41bc98f..0b72725 100644 --- a/lib/setup/profile.js +++ b/lib/setup/profile.js @@ -88,7 +88,7 @@ var shellInitScriptChooser = function() { var bashrcNotExist; // Check if .bash_profile exists - return fs.access(bash_profileFile) + return fs.access(bashProfileFile) .catch(function(err) { bashProfileNotExist = err; }) @@ -125,11 +125,11 @@ var shellInitScriptChooser = function() { .then(function(data) { // RegExp to detect "~/.bash_profile", // "$HOME/.bash_profile", or "/home/user/.bash_profile" - var bash_profileRe = new RegExp(' ?source +(\\\\\\n)? *' + + var bashProfileRe = new RegExp(' ?source +(\\\\\\n)? *' + '(~\/.bash_profile|\"?\\$HOME\/.bash_profile\"?|' + '[\'\"]?\/home\/\\w+\/.bash_profile[\'\"]?)'); - if(bash_profileRe.test(data)) { + if(bashProfileRe.test(data)) { return bashProfileFileName; } return; From 569aa22f36d687111ed628821a895c1c23edb280 Mon Sep 17 00:00:00 2001 From: Ed Solis Date: Mon, 23 Jan 2017 16:36:39 -0600 Subject: [PATCH 08/10] Fix style: if keyword --- lib/setup/profile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/setup/profile.js b/lib/setup/profile.js index 0b72725..f372182 100644 --- a/lib/setup/profile.js +++ b/lib/setup/profile.js @@ -129,7 +129,7 @@ var shellInitScriptChooser = function() { '(~\/.bash_profile|\"?\\$HOME\/.bash_profile\"?|' + '[\'\"]?\/home\/\\w+\/.bash_profile[\'\"]?)'); - if(bashProfileRe.test(data)) { + if (bashProfileRe.test(data)) { return bashProfileFileName; } return; From 644106496a1d2fd7dbe6c50b06f7c4de8d5b7fb6 Mon Sep 17 00:00:00 2001 From: Ed Solis Date: Mon, 23 Jan 2017 16:43:44 -0600 Subject: [PATCH 09/10] Don't forget to return Promises --- lib/setup/profile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/setup/profile.js b/lib/setup/profile.js index f372182..d120378 100644 --- a/lib/setup/profile.js +++ b/lib/setup/profile.js @@ -181,7 +181,7 @@ module.exports.update = function() { appendFile = initScript; if (appendFile === bashProfileFileName) { - Promise.map([bashProfileFileName, '.zshrc'], function(name) { + return Promise.map([bashProfileFileName, '.zshrc'], function(name) { return appendScript(name); }) .each(function(result) { From 5bca4a72381139299afab25dbc2f78453b3c97b3 Mon Sep 17 00:00:00 2001 From: Ed Solis Date: Mon, 23 Jan 2017 17:11:49 -0600 Subject: [PATCH 10/10] Make NodeJS 0.10 compatible --- lib/setup/profile.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/setup/profile.js b/lib/setup/profile.js index d120378..a2a4932 100644 --- a/lib/setup/profile.js +++ b/lib/setup/profile.js @@ -87,15 +87,18 @@ var shellInitScriptChooser = function() { var bashProfileNotExist; var bashrcNotExist; + // Notice: will change fs.stat to fs.access in the future + // Reason: NodeJS 0.10 doesn't have fs.access (added in NodeJS 0.11.15) + // Check if .bash_profile exists - return fs.access(bashProfileFile) + return fs.stat(bashProfileFile) .catch(function(err) { bashProfileNotExist = err; }) // Check if .bashrc exists .then(function() { - return fs.access(bashrcFile) + return fs.stat(bashrcFile) .catch(function(err) { bashrcNotExist = err; });