1
- 'use strict' ;
2
-
3
- var fs = require ( 'fs-extra' ) ;
4
- var ng = require ( '../helpers/ng' ) ;
5
- var existsSync = require ( 'exists-sync' ) ;
6
- var expect = require ( 'chai' ) . expect ;
7
- var forEach = require ( 'lodash/forEach' ) ;
8
- var walkSync = require ( 'walk-sync' ) ;
9
- var Blueprint = require ( 'angular-cli/ember-cli/lib/models/blueprint' ) ;
10
- var path = require ( 'path' ) ;
11
- var tmp = require ( '../helpers/tmp' ) ;
12
- var root = process . cwd ( ) ;
13
- var util = require ( 'util' ) ;
14
- var EOL = require ( 'os' ) . EOL ;
15
- var SilentError = require ( 'silent-error' ) ;
1
+ const fs = require ( 'fs-extra' ) ;
2
+ const ng = require ( '../helpers/ng' ) ;
3
+ const existsSync = require ( 'exists-sync' ) ;
4
+ const expect = require ( 'chai' ) . expect ;
5
+ const forEach = require ( 'lodash/forEach' ) ;
6
+ const walkSync = require ( 'walk-sync' ) ;
7
+ const Blueprint = require ( 'angular-cli/ember-cli/lib/models/blueprint' ) ;
8
+ const path = require ( 'path' ) ;
9
+ const tmp = require ( '../helpers/tmp' ) ;
10
+ const root = process . cwd ( ) ;
11
+ const util = require ( 'util' ) ;
12
+ const EOL = require ( 'os' ) . EOL ;
13
+ const SilentError = require ( 'silent-error' ) ;
14
+
16
15
17
16
describe ( 'Acceptance: ng new' , function ( ) {
18
17
beforeEach ( function ( ) {
@@ -29,10 +28,10 @@ describe('Acceptance: ng new', function () {
29
28
30
29
function confirmBlueprintedForDir ( dir ) {
31
30
return function ( ) {
32
- var blueprintPath = path . join ( root , dir , 'files' ) ;
33
- var expected = walkSync ( blueprintPath ) ;
34
- var actual = walkSync ( '.' ) . sort ( ) ;
35
- var directory = path . basename ( process . cwd ( ) ) ;
31
+ let blueprintPath = path . join ( root , dir , 'files' ) ;
32
+ let expected = walkSync ( blueprintPath ) ;
33
+ let actual = walkSync ( '.' ) . sort ( ) ;
34
+ let directory = path . basename ( process . cwd ( ) ) ;
36
35
37
36
forEach ( Blueprint . renamedFiles , function ( destFile , srcFile ) {
38
37
expected [ expected . indexOf ( srcFile ) ] = destFile ;
@@ -56,6 +55,28 @@ describe('Acceptance: ng new', function () {
56
55
return confirmBlueprintedForDir ( 'blueprints/ng2' ) ;
57
56
}
58
57
58
+ it ( 'requires a valid name (!)' , ( ) => {
59
+ return ng ( [ 'new' , '!' , '--skip-npm' , '--skip-git' , '--inline-template' ] ) . then ( ( ) => { throw new Error ( ) ; } , ( ) => { } ) ;
60
+ } ) ;
61
+ it ( 'requires a valid name (abc-.)' , ( ) => {
62
+ return ng ( [ 'new' , 'abc-.' , '--skip-npm' , '--skip-git' , '--inline-template' ] ) . then ( ( ) => { throw new Error ( ) ; } , ( ) => { } ) ;
63
+ } ) ;
64
+ it ( 'requires a valid name (abc-)' , ( ) => {
65
+ return ng ( [ 'new' , 'abc-' , '--skip-npm' , '--skip-git' , '--inline-template' ] ) . then ( ( ) => { throw new Error ( ) ; } , ( ) => { } ) ;
66
+ } ) ;
67
+ it ( 'requires a valid name (abc-def-)' , ( ) => {
68
+ return ng ( [ 'new' , 'abc-def-' , '--skip-npm' , '--skip-git' , '--inline-template' ] ) . then ( ( ) => { throw new Error ( ) ; } , ( ) => { } ) ;
69
+ } ) ;
70
+ it ( 'requires a valid name (abc-123)' , ( ) => {
71
+ return ng ( [ 'new' , 'abc-123' , '--skip-npm' , '--skip-git' , '--inline-template' ] ) . then ( ( ) => { throw new Error ( ) ; } , ( ) => { } ) ;
72
+ } ) ;
73
+ it ( 'requires a valid name (abc)' , ( ) => {
74
+ return ng ( [ 'new' , 'abc' , '--skip-npm' , '--skip-git' , '--inline-template' ] ) ;
75
+ } ) ;
76
+ it ( 'requires a valid name (abc-def)' , ( ) => {
77
+ return ng ( [ 'new' , 'abc-def' , '--skip-npm' , '--skip-git' , '--inline-template' ] ) ;
78
+ } ) ;
79
+
59
80
it ( 'ng new foo, where foo does not yet exist, works' , function ( ) {
60
81
return ng ( [ 'new' , 'foo' , '--skip-npm' , '--skip-bower' ] ) . then ( confirmBlueprinted ) ;
61
82
} ) ;
@@ -72,7 +93,7 @@ describe('Acceptance: ng new', function () {
72
93
return ng ( [ 'new' , 'FooApp' , '--skip-npm' , '--skip-bower' , '--skip-git' ] ) . then ( function ( ) {
73
94
expect ( ! existsSync ( 'FooApp' ) ) ;
74
95
75
- var pkgJson = JSON . parse ( fs . readFileSync ( 'package.json' , 'utf8' ) ) ;
96
+ const pkgJson = JSON . parse ( fs . readFileSync ( 'package.json' , 'utf8' ) ) ;
76
97
expect ( pkgJson . name ) . to . equal ( 'foo-app' ) ;
77
98
} ) ;
78
99
} ) ;
@@ -81,7 +102,7 @@ describe('Acceptance: ng new', function () {
81
102
return ng ( [ 'new' , 'FooApp' , '--skip-npm' , '--skip-bower' , '--skip-git' ] ) . then ( function ( ) {
82
103
expect ( ! existsSync ( 'FooApp' ) ) ;
83
104
84
- var editorConfig = fs . readFileSync ( '.editorconfig' , 'utf8' ) ;
105
+ const editorConfig = fs . readFileSync ( '.editorconfig' , 'utf8' ) ;
85
106
expect ( editorConfig ) . to . exist ;
86
107
} ) ;
87
108
} ) ;
@@ -106,7 +127,7 @@ describe('Acceptance: ng new', function () {
106
127
107
128
it ( 'ng new with --dry-run does not create new directory' , function ( ) {
108
129
return ng ( [ 'new' , 'foo' , '--dry-run' ] ) . then ( function ( ) {
109
- var cwd = process . cwd ( ) ;
130
+ const cwd = process . cwd ( ) ;
110
131
expect ( cwd ) . to . not . match ( / f o o / , 'does not change cwd to foo in a dry run' ) ;
111
132
expect ( ! existsSync ( path . join ( cwd , 'foo' ) ) , 'does not create new directory' ) ;
112
133
expect ( ! existsSync ( path . join ( cwd , '.git' ) ) , 'does not create git in current directory' ) ;
@@ -116,14 +137,14 @@ describe('Acceptance: ng new', function () {
116
137
it ( 'ng new with --directory uses given directory name and has correct package name' , function ( ) {
117
138
return ng ( [ 'new' , 'foo' , '--skip-npm' , '--skip-bower' , '--skip-git' , '--directory=bar' ] )
118
139
. then ( function ( ) {
119
- var cwd = process . cwd ( ) ;
140
+ const cwd = process . cwd ( ) ;
120
141
expect ( cwd ) . to . not . match ( / f o o / , 'does not use app name for directory name' ) ;
121
142
expect ( ! existsSync ( path . join ( cwd , 'foo' ) ) , 'does not create new directory with app name' ) ;
122
143
123
144
expect ( cwd ) . to . match ( / b a r / , 'uses given directory name' ) ;
124
145
expect ( existsSync ( path . join ( cwd , 'bar' ) ) , 'creates new directory with specified name' ) ;
125
146
126
- var pkgJson = JSON . parse ( fs . readFileSync ( 'package.json' , 'utf8' ) ) ;
147
+ const pkgJson = JSON . parse ( fs . readFileSync ( 'package.json' , 'utf8' ) ) ;
127
148
expect ( pkgJson . name ) . to . equal ( 'foo' , 'uses app name for package name' ) ;
128
149
} ) ;
129
150
} ) ;
0 commit comments