Skip to content

Commit 9de2157

Browse files
committed
fix(bower): change check for bower to use execSync.
1 parent c4ee8eb commit 9de2157

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

lib/utils/bower.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,9 @@ function saveData(bowerData) {
4949

5050
function checkForBower() {
5151
try {
52-
var result = childProcess.exec('bower -v', { silent: true });
53-
if (result.hasOwnProperty('output') &&
54-
result.output.indexOf('command not found') === -1 &&
55-
result.output.indexOf('not recognized') === -1) {
52+
var result = childProcess.execSync('bower -v', { silent: true, encoding: 'utf8' });
53+
if (result.indexOf('command not found') === -1 &&
54+
result.indexOf('not recognized') === -1) {
5655
return true;
5756
}
5857
} catch (ex) {} // eslint-disable-line no-empty

spec/utils/bower.spec.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,31 +149,30 @@ describe('saveData function', function() {
149149

150150
describe('checkForBower function', function() {
151151
it('should return true if bower is installed', function() {
152-
spyOn(childProcess, 'exec').andReturn({
153-
output: '0'
154-
});
152+
spyOn(childProcess, 'execSync').andReturn('1.7.9\n');
153+
var result = bowerUtils.checkForBower();
154+
expect(result).toEqual(true);
155+
});
156+
it('should return true if bower is installed', function() {
157+
spyOn(childProcess, 'execSync').andReturn('0');
155158
var result = bowerUtils.checkForBower();
156159
expect(result).toEqual(true);
157160
});
158161

159162
it('should return false if bower exec returns "command not found"', function() {
160-
spyOn(childProcess, 'exec').andReturn({
161-
output: 'command not found'
162-
});
163+
spyOn(childProcess, 'execSync').andReturn('command not found');
163164
var result = bowerUtils.checkForBower();
164165
expect(result).toEqual(false);
165166
});
166167

167168
it('should return false if bower exec returns "not recognized"', function() {
168-
spyOn(childProcess, 'exec').andReturn({
169-
output: 'not recognized'
170-
});
169+
spyOn(childProcess, 'execSync').andReturn('not recognized');
171170
var result = bowerUtils.checkForBower();
172171
expect(result).toEqual(false);
173172
});
174173

175174
it('should return false if bower exec throws an error', function() {
176-
spyOn(childProcess, 'exec').andCallFake(function() {
175+
spyOn(childProcess, 'execSync').andCallFake(function() {
177176
throw new Error('something happened');
178177
});
179178
var result = bowerUtils.checkForBower();

0 commit comments

Comments
 (0)