Skip to content

Commit 537bb82

Browse files
committed
removed adding providers when generating a new server
1 parent d22250e commit 537bb82

2 files changed

Lines changed: 6 additions & 16 deletions

File tree

β€Žaddon/ng2/blueprints/service/index.jsβ€Ž

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ var dynamicPathParser = require('../../utilities/dynamic-path-parser');
44
var addBarrelRegistration = require('../../utilities/barrel-management');
55
var getFiles = Blueprint.prototype.files;
66
const stringUtils = require('ember-cli-string-utils');
7-
const astUtils = require('../../utilities/ast-utils');
87

98
module.exports = {
109
description: '',
11-
10+
1211
availableOptions: [
1312
{ name: 'flat', type: Boolean, default: true }
1413
],
@@ -26,10 +25,10 @@ module.exports = {
2625
flat: options.flat
2726
};
2827
},
29-
28+
3029
files: function() {
3130
var fileList = getFiles.call(this);
32-
31+
3332
if (this.options && this.options.flat) {
3433
fileList = fileList.filter(p => p.indexOf('index.ts') <= 0);
3534
}
@@ -50,26 +49,17 @@ module.exports = {
5049
}
5150
};
5251
},
53-
52+
5453
afterInstall: function(options) {
5554
const returns = [];
5655
const fileName = stringUtils.dasherize(`${options.entity.name}.service`);
57-
const modulePath = path.join(this.project.root, this.dynamicPath.appRoot, 'app.module.ts');
58-
const componentDir = path.relative(this.dynamicPath.appRoot, this.generatePath);
59-
const importPath = componentDir ? `./${componentDir}/${fileName}` : `./${fileName}`;
60-
const className = stringUtils.classify(`${options.entity.name}Service`);
6156

6257
if (!options.flat) {
6358
returns.push(addBarrelRegistration(this, this.generatePath));
6459
} else {
6560
returns.push(addBarrelRegistration(this, this.generatePath, fileName));
6661
}
6762

68-
returns.push(
69-
astUtils.addProviderToModule(modulePath, className, importPath)
70-
.then(change => change.apply()));
71-
72-
7363
return Promise.all(returns);
7464
}
7565
};

β€Žtests/acceptance/generate-service.spec.jsβ€Ž

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ describe('Acceptance: ng generate service', function () {
4343
.then(() => expect(existsSync(testPath)).to.equal(true))
4444
.then(() => readFile(appModulePath, 'utf-8'))
4545
.then(content => {
46-
expect(content).matches(/import.*\MySvcService\b.*from '.\/my-svc.service';/);
47-
expect(content).matches(/providers:\s*\[MySvcService\]/m);
46+
expect(content).not.to.matches(/import.*\MySvcService\b.*from '.\/my-svc.service';/);
47+
expect(content).not.to.matches(/providers:\s*\[MySvcService\]/m);
4848
});
4949
});
5050

0 commit comments

Comments
 (0)