Skip to content

Commit b6fb613

Browse files
committed
fix(paths): fix the determination of execution path
Windows does not populate this fix allows for determination of the directory from which an ng command was executed Fixes angular#297
1 parent 6607ebb commit b6fb613

File tree

6 files changed

+11
-21
lines changed

6 files changed

+11
-21
lines changed

addon/ng2/blueprints/component/index.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@ module.exports = {
55
description: '',
66

77
normalizeEntityName: function(entityName) {
8-
var cwd = this.project.cli.testing
9-
? process.cwd()
10-
: process.env.PWD;
118

12-
var parsedPath = dynamicPathParser(cwd, this.project.root, entityName);
9+
var parsedPath = dynamicPathParser(this.project.root, entityName);
1310

1411
this.dynamicPath = parsedPath;
1512
return parsedPath.name;

addon/ng2/blueprints/directive/index.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@ module.exports = {
55
description: '',
66

77
normalizeEntityName: function(entityName) {
8-
var cwd = this.project.cli.testing
9-
? process.cwd()
10-
: process.env.PWD;
11-
12-
var parsedPath = dynamicPathParser(cwd, this.project.root, entityName);
8+
var parsedPath = dynamicPathParser(this.project.root, entityName);
139

1410
this.dynamicPath = parsedPath;
1511
return parsedPath.name;

addon/ng2/blueprints/pipe/index.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@ module.exports = {
55
description: '',
66

77
normalizeEntityName: function(entityName) {
8-
var cwd = this.project.cli.testing
9-
? process.cwd()
10-
: process.env.PWD;
11-
12-
var parsedPath = dynamicPathParser(cwd, this.project.root, entityName);
8+
var parsedPath = dynamicPathParser(this.project.root, entityName);
139

1410
this.dynamicPath = parsedPath;
1511
return parsedPath.name;

addon/ng2/blueprints/service/index.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@ module.exports = {
55
description: '',
66

77
normalizeEntityName: function(entityName) {
8-
var cwd = this.project.cli.testing
9-
? process.cwd()
10-
: process.env.PWD;
11-
12-
var parsedPath = dynamicPathParser(cwd, this.project.root, entityName);
8+
var parsedPath = dynamicPathParser(this.project.root, entityName);
139

1410
this.dynamicPath = parsedPath;
1511
return parsedPath.name;

addon/ng2/utilities/dynamic-path-parser.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
var path = require('path');
22
var process = require('process');
33

4-
module.exports = function dynamicPathParser(cwd, projectRoot, entityName) {
4+
module.exports = function dynamicPathParser(projectRoot, entityName) {
5+
var cwd = process.env.runFromPath;
6+
57
var rootPath = path.join(projectRoot, 'src', 'app');
68

79
var outputPath = path.join(rootPath, entityName);

lib/cli/index.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ module.exports = function (options) {
2727
root: path.join(__dirname, '..', '..'),
2828
npmPackage: 'angular-cli'
2929
};
30-
30+
31+
// add environemnt variable for dynamic paths
32+
process.env.runFromPath = process.cwd();
33+
3134
return cli(options);
3235
};

0 commit comments

Comments
 (0)