Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions addon/ng2/blueprints/component/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ module.exports = {
description: '',

normalizeEntityName: function(entityName) {
var cwd = this.project.cli.testing
? process.cwd()
: process.env.PWD;

var parsedPath = dynamicPathParser(cwd, this.project.root, entityName);
var parsedPath = dynamicPathParser(this.project, entityName);

this.dynamicPath = parsedPath;
return parsedPath.name;
Expand Down
6 changes: 1 addition & 5 deletions addon/ng2/blueprints/directive/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ module.exports = {
description: '',

normalizeEntityName: function(entityName) {
var cwd = this.project.cli.testing
? process.cwd()
: process.env.PWD;

var parsedPath = dynamicPathParser(cwd, this.project.root, entityName);
var parsedPath = dynamicPathParser(this.project, entityName);

this.dynamicPath = parsedPath;
return parsedPath.name;
Expand Down
6 changes: 1 addition & 5 deletions addon/ng2/blueprints/pipe/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ module.exports = {
description: '',

normalizeEntityName: function(entityName) {
var cwd = this.project.cli.testing
? process.cwd()
: process.env.PWD;

var parsedPath = dynamicPathParser(cwd, this.project.root, entityName);
var parsedPath = dynamicPathParser(this.project, entityName);

this.dynamicPath = parsedPath;
return parsedPath.name;
Expand Down
6 changes: 1 addition & 5 deletions addon/ng2/blueprints/service/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ module.exports = {
description: '',

normalizeEntityName: function(entityName) {
var cwd = this.project.cli.testing
? process.cwd()
: process.env.PWD;

var parsedPath = dynamicPathParser(cwd, this.project.root, entityName);
var parsedPath = dynamicPathParser(this.project, entityName);

this.dynamicPath = parsedPath;
return parsedPath.name;
Expand Down
5 changes: 4 additions & 1 deletion addon/ng2/utilities/dynamic-path-parser.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
var path = require('path');
var process = require('process');

module.exports = function dynamicPathParser(cwd, projectRoot, entityName) {
module.exports = function dynamicPathParser(project, entityName) {
var projectRoot = project.root;
var cwd = process.env.PWD;

var rootPath = path.join(projectRoot, 'src', 'app');

var outputPath = path.join(rootPath, entityName);
Expand Down
5 changes: 4 additions & 1 deletion lib/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ module.exports = function(options) {
root: path.join(__dirname, '..', '..'),
npmPackage: 'angular-cli'
};


// ensure the environemnt variable for dynamic paths
process.env.PWD = process.env.PWD || process.cwd();

return cli(options);
}
4 changes: 0 additions & 4 deletions tests/acceptance/generate-component.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ describe('Acceptance: ng generate component', function() {
.then(_ => fs.mkdirsSync('./1'))
.then(_ => process.chdir('./1'))
.then(_ => {
process.env.CWD = process.cwd();
return ng([
'generate',
'component',
Expand All @@ -109,7 +108,6 @@ describe('Acceptance: ng generate component', function() {
.then(_ => fs.mkdirsSync('./1'))
.then(_ => process.chdir('./1'))
.then(_ => {
process.env.CWD = process.cwd();
return ng([
'generate',
'component',
Expand All @@ -131,7 +129,6 @@ describe('Acceptance: ng generate component', function() {
.then(_ => fs.mkdirsSync('./1'))
.then(_ => process.chdir('./1'))
.then(_ => {
process.env.CWD = process.cwd();
return ng([
'generate',
'component',
Expand All @@ -153,7 +150,6 @@ describe('Acceptance: ng generate component', function() {
.then(_ => fs.mkdirsSync('./1'))
.then(_ => process.chdir('./1'))
.then(_ => {
process.env.CWD = process.cwd();
return ng([
'generate',
'component',
Expand Down
4 changes: 3 additions & 1 deletion tests/helpers/ng.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ var Cli = require('../../lib/cli');

module.exports = function ng(args) {
var cli;


process.env.PWD = process.cwd();

cli = new Cli({
inputStream: [],
outputStream: [],
Expand Down