Skip to content

Commit aa44c2a

Browse files
committed
Mock npm-install
1 parent 5194c65 commit aa44c2a

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

node-tests/blueprints/ember-cli-typescript-test.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
'use strict';
22

3-
const fs = require('fs');
3+
const fs = require('fs-extra');
44
const path = require('path');
55
const helpers = require('ember-cli-blueprint-test-helpers/helpers');
66
const chaiHelpers = require('ember-cli-blueprint-test-helpers/chai');
7+
const Blueprint = require('ember-cli/lib/models/blueprint');
78

89
const ects = require('../../blueprints/ember-cli-typescript');
910

@@ -13,6 +14,31 @@ const file = chaiHelpers.file;
1314
describe('Acceptance: ember-cli-typescript generator', function() {
1415
helpers.setupTestHooks(this, { disabledTasks: ['addon-install', 'bower-install'] });
1516

17+
const originalTaskForFn = Blueprint.prototype.taskFor;
18+
19+
beforeEach(function() {
20+
Blueprint.prototype.taskFor = function(taskName) {
21+
if (taskName === 'npm-install') {
22+
// Mock npm-install that only modifies package.json
23+
return {
24+
run: function(options) {
25+
let pkgJson = fs.readJsonSync('package.json')
26+
options.packages.forEach(function(pkg) {
27+
let pkgName = pkg.match(/^(.*)@[^@]*$/);
28+
pkgJson['devDependencies'][pkgName[1]] = '*';
29+
});
30+
fs.writeJsonSync('package.json', pkgJson);
31+
}
32+
}
33+
}
34+
return originalTaskForFn.call(this, taskName);
35+
};
36+
});
37+
38+
afterEach(function() {
39+
Blueprint.prototype.taskFor = originalTaskForFn;
40+
});
41+
1642
it('basic app', function() {
1743
const args = ['ember-cli-typescript'];
1844

0 commit comments

Comments
 (0)