Skip to content

Commit 26486d2

Browse files
buchslavajthoms1
authored andcommitted
fix(cli): npm install under windows (#1539)
Closes #1445
1 parent 58cfd8a commit 26486d2

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

lib/cli.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ var Logging = IonicAppLib.logging;
1818
var log = Logging.logger;
1919
var Q = require('q');
2020
var helpUtil = require('./utils/help');
21+
var EOL = require('os').EOL;
2122

2223
Cli.ALL_TASKS = Tasks;
2324
Cli.IONIC_DASH = 'https://apps.ionic.io';
@@ -268,7 +269,7 @@ Cli.loadGulpfile = function loadGulpfile() {
268269
var names = ['gulpfile.js', 'Gulpfile.js'];
269270
for (var i = 0, ii = names.length; i < ii; i += 1) {
270271
try {
271-
require(path.resolve(process.cwd() + '/' + names[i]));
272+
require(path.resolve(process.cwd(), names[i]));
272273
log.verbose('Gulpfile found');
273274
return true;
274275
} catch (e) {
@@ -331,7 +332,7 @@ Cli.runNpmHook = function runNpmHook(hook) {
331332
});
332333
spawned.stdout.pipe(process.stdout);
333334
spawned.stdout.on('data', function(data) {
334-
var dataLines = data.toString().split('\n');
335+
var dataLines = data.toString().split(EOL);
335336
for (var i = 0; i < dataLines.length; i++) {
336337
if (dataLines[i].length) {
337338
if (dataLines[i].indexOf('watch ready') > -1) {
@@ -360,7 +361,7 @@ Cli.loadNpmScripts = function loadNpmScripts() {
360361
var fileName = 'package.json';
361362

362363
try {
363-
var packageFile = require(path.resolve(process.cwd() + '/' + fileName));
364+
var packageFile = require(path.resolve(process.cwd(), fileName));
364365
log.verbose('Package.json found scripts:', packageFile.scripts);
365366
return packageFile.scripts;
366367
} catch (e) {

lib/utils/help.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
var IonicAppLib = require('ionic-app-lib');
44
var log = IonicAppLib.logging.logger;
5+
var EOL = require('os').EOL;
56
require('colors');
67

78
/**
@@ -173,7 +174,7 @@ function printTaskDetails(d) {
173174
}
174175
w((indent + ' ' + arg + ' ').bold);
175176

176-
var argDescs = d.args[arg].split('\n');
177+
var argDescs = d.args[arg].split(EOL);
177178
var argIndent = indent + ' ';
178179

179180
for (x = 0; x < arg.length + 1; x += 1) {
@@ -218,9 +219,9 @@ function printTaskDetails(d) {
218219
var optDescs;
219220

220221
if (typeof taskOpt == 'string') {
221-
optDescs = taskOpt.split('\n');
222+
optDescs = taskOpt.split(EOL);
222223
} else {
223-
optDescs = taskOpt.title.split('\n');
224+
optDescs = taskOpt.title.split(EOL);
224225
}
225226
for (x = 0; x < optDescs.length; x += 1) {
226227
if (x === 0) {

spec/utils/templates.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ var rewire = require('rewire');
55
var templateUtils = rewire('../../lib/utils/templates');
66
var IonicAppLib = require('ionic-app-lib');
77
var log = IonicAppLib.logging.logger;
8+
var EOL = require('os').EOL;
89

910
describe('listTemplates method', function() {
1011
it('should should call fetchStarterTemplates pull out templates/sort and send to list', function(done) {
@@ -148,7 +149,7 @@ describe('list function', function() {
148149
var list = templateUtils.__get__('list');
149150

150151
list(templates);
151-
expect(log.info.calls[0].args).toEqual(['\n']);
152+
expect(log.info.calls[0].args).toEqual([EOL]);
152153
expect(log.info.calls[1].args[0]).toMatch('a-template'); // Use match because of colors
153154
expect(log.info.calls[1].args[1]).toEqual('...........');
154155
expect(log.info.calls[1].args[2]).toEqual(templates[0].description);

0 commit comments

Comments
 (0)