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,33 @@ 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' ] )
60
+ . then ( ( ) => { throw new Error ( ) ; } , ( ) => { } ) ;
61
+ } ) ;
62
+ it ( 'requires a valid name (abc-.)' , ( ) => {
63
+ return ng ( [ 'new' , 'abc-.' , '--skip-npm' , '--skip-git' , '--inline-template' ] )
64
+ . then ( ( ) => { throw new Error ( ) ; } , ( ) => { } ) ;
65
+ } ) ;
66
+ it ( 'requires a valid name (abc-)' , ( ) => {
67
+ return ng ( [ 'new' , 'abc-' , '--skip-npm' , '--skip-git' , '--inline-template' ] )
68
+ . then ( ( ) => { throw new Error ( ) ; } , ( ) => { } ) ;
69
+ } ) ;
70
+ it ( 'requires a valid name (abc-def-)' , ( ) => {
71
+ return ng ( [ 'new' , 'abc-def-' , '--skip-npm' , '--skip-git' , '--inline-template' ] )
72
+ . then ( ( ) => { throw new Error ( ) ; } , ( ) => { } ) ;
73
+ } ) ;
74
+ it ( 'requires a valid name (abc-123)' , ( ) => {
75
+ return ng ( [ 'new' , 'abc-123' , '--skip-npm' , '--skip-git' , '--inline-template' ] )
76
+ . then ( ( ) => { throw new Error ( ) ; } , ( ) => { } ) ;
77
+ } ) ;
78
+ it ( 'requires a valid name (abc)' , ( ) => {
79
+ return ng ( [ 'new' , 'abc' , '--skip-npm' , '--skip-git' , '--inline-template' ] ) ;
80
+ } ) ;
81
+ it ( 'requires a valid name (abc-def)' , ( ) => {
82
+ return ng ( [ 'new' , 'abc-def' , '--skip-npm' , '--skip-git' , '--inline-template' ] ) ;
83
+ } ) ;
84
+
59
85
it ( 'ng new foo, where foo does not yet exist, works' , function ( ) {
60
86
return ng ( [ 'new' , 'foo' , '--skip-npm' , '--skip-bower' ] ) . then ( confirmBlueprinted ) ;
61
87
} ) ;
@@ -72,7 +98,7 @@ describe('Acceptance: ng new', function () {
72
98
return ng ( [ 'new' , 'FooApp' , '--skip-npm' , '--skip-bower' , '--skip-git' ] ) . then ( function ( ) {
73
99
expect ( ! existsSync ( 'FooApp' ) ) ;
74
100
75
- var pkgJson = JSON . parse ( fs . readFileSync ( 'package.json' , 'utf8' ) ) ;
101
+ const pkgJson = JSON . parse ( fs . readFileSync ( 'package.json' , 'utf8' ) ) ;
76
102
expect ( pkgJson . name ) . to . equal ( 'foo-app' ) ;
77
103
} ) ;
78
104
} ) ;
@@ -81,7 +107,7 @@ describe('Acceptance: ng new', function () {
81
107
return ng ( [ 'new' , 'FooApp' , '--skip-npm' , '--skip-bower' , '--skip-git' ] ) . then ( function ( ) {
82
108
expect ( ! existsSync ( 'FooApp' ) ) ;
83
109
84
- var editorConfig = fs . readFileSync ( '.editorconfig' , 'utf8' ) ;
110
+ const editorConfig = fs . readFileSync ( '.editorconfig' , 'utf8' ) ;
85
111
expect ( editorConfig ) . to . exist ;
86
112
} ) ;
87
113
} ) ;
@@ -93,7 +119,7 @@ describe('Acceptance: ng new', function () {
93
119
throw new SilentError ( 'Cannot run ng new, inside of ember-cli project should fail.' ) ;
94
120
} , ( ) => {
95
121
expect ( ! existsSync ( 'foo' ) ) ;
96
- } )
122
+ } ) ;
97
123
} )
98
124
. then ( confirmBlueprinted ) ;
99
125
} ) ;
@@ -106,7 +132,7 @@ describe('Acceptance: ng new', function () {
106
132
107
133
it ( 'ng new with --dry-run does not create new directory' , function ( ) {
108
134
return ng ( [ 'new' , 'foo' , '--dry-run' ] ) . then ( function ( ) {
109
- var cwd = process . cwd ( ) ;
135
+ const cwd = process . cwd ( ) ;
110
136
expect ( cwd ) . to . not . match ( / f o o / , 'does not change cwd to foo in a dry run' ) ;
111
137
expect ( ! existsSync ( path . join ( cwd , 'foo' ) ) , 'does not create new directory' ) ;
112
138
expect ( ! existsSync ( path . join ( cwd , '.git' ) ) , 'does not create git in current directory' ) ;
@@ -116,14 +142,14 @@ describe('Acceptance: ng new', function () {
116
142
it ( 'ng new with --directory uses given directory name and has correct package name' , function ( ) {
117
143
return ng ( [ 'new' , 'foo' , '--skip-npm' , '--skip-bower' , '--skip-git' , '--directory=bar' ] )
118
144
. then ( function ( ) {
119
- var cwd = process . cwd ( ) ;
145
+ const cwd = process . cwd ( ) ;
120
146
expect ( cwd ) . to . not . match ( / f o o / , 'does not use app name for directory name' ) ;
121
147
expect ( ! existsSync ( path . join ( cwd , 'foo' ) ) , 'does not create new directory with app name' ) ;
122
148
123
149
expect ( cwd ) . to . match ( / b a r / , 'uses given directory name' ) ;
124
150
expect ( existsSync ( path . join ( cwd , 'bar' ) ) , 'creates new directory with specified name' ) ;
125
151
126
- var pkgJson = JSON . parse ( fs . readFileSync ( 'package.json' , 'utf8' ) ) ;
152
+ const pkgJson = JSON . parse ( fs . readFileSync ( 'package.json' , 'utf8' ) ) ;
127
153
expect ( pkgJson . name ) . to . equal ( 'foo' , 'uses app name for package name' ) ;
128
154
} ) ;
129
155
} ) ;
0 commit comments