1
- " use strict" ;
1
+ ' use strict' ;
2
2
3
- var Generator = require ( " yeoman-generator" ) ;
4
- var path = require ( " path" ) ;
5
- var yosay = require ( " yosay" ) ;
3
+ var Generator = require ( ' yeoman-generator' ) ;
4
+ var path = require ( ' path' ) ;
5
+ var yosay = require ( ' yosay' ) ;
6
6
7
7
module . exports = class extends Generator {
8
8
constructor ( args , opts ) {
9
9
super ( args , opts ) ;
10
10
11
- this . option ( " name" , {
12
- desc : " Module name" ,
13
- alias : "n" ,
11
+ this . option ( ' name' , {
12
+ desc : ' Module name' ,
13
+ alias : 'n' ,
14
14
type : String
15
15
} ) ;
16
- this . option ( " repository" , {
17
- desc : " Docker image repository for your module" ,
18
- alias : "r" ,
16
+ this . option ( ' repository' , {
17
+ desc : ' Docker image repository for your module' ,
18
+ alias : 'r' ,
19
19
type : String
20
20
} ) ;
21
21
}
22
22
23
23
prompting ( ) {
24
- this . log ( yosay ( " Hey You\r\nWelcome to Azure IoT Edge module generator" ) ) ;
24
+ this . log ( yosay ( ' Hey You\r\nWelcome to Azure IoT Edge module generator' ) ) ;
25
25
26
26
return this . prompt ( [
27
27
{
28
- type : " input" ,
29
- name : " name" ,
30
- message : " What's the name of your module?" ,
31
- default : " SampleModule" ,
28
+ type : ' input' ,
29
+ name : ' name' ,
30
+ message : ' What\ 's the name of your module?' ,
31
+ default : ' SampleModule' ,
32
32
when : ( ) => {
33
33
return ! this . options . name ; // skip the prompt when the value is already passed as a command option
34
34
} ,
35
35
validate : ( name ) => {
36
36
if ( ! name ) {
37
- return " Module name could not be empty" ;
37
+ return ' Module name could not be empty' ;
38
38
}
39
- if ( name . startsWith ( "_" ) || name . endsWith ( "_" ) ) {
40
- return " Module name must not start or end with the symbol _" ;
39
+ if ( name . startsWith ( '_' ) || name . endsWith ( '_' ) ) {
40
+ return ' Module name must not start or end with the symbol _' ;
41
41
}
42
42
if ( name . match ( / [ ^ a - z A - Z 0 - 9 \_ ] / ) ) {
43
- return " Module name must contain only alphanumeric characters or the symbol _" ;
43
+ return ' Module name must contain only alphanumeric characters or the symbol _' ;
44
44
}
45
45
return true ;
46
46
}
47
47
} ,
48
48
{
49
- type : " input" ,
50
- name : " repository" ,
51
- " message" : " What's the Docker image repository for your module?" ,
49
+ type : ' input' ,
50
+ name : ' repository' ,
51
+ message : ' What\ 's the Docker image repository for your module?' ,
52
52
when : ( ) => {
53
53
return ! this . options . repository ; // skip the prompt when the value is already passed as a command option
54
54
} ,
@@ -66,13 +66,13 @@ module.exports = class extends Generator {
66
66
writing ( ) {
67
67
this . log ( `Creating ${ this . name } module at ${ this . repository } ...` ) ;
68
68
69
- this . _copyStatic ( " gitignore" , " .gitignore" ) ;
70
- this . _copyStatic ( " app.js" ) ;
71
- this . _copyStatic ( " Dockerfile" ) ;
72
- this . _copyStatic ( " Dockerfile.windows-amd64" ) ;
69
+ this . _copyStatic ( ' gitignore' , ' .gitignore' ) ;
70
+ this . _copyStatic ( ' app.js' ) ;
71
+ this . _copyStatic ( ' Dockerfile' ) ;
72
+ this . _copyStatic ( ' Dockerfile.windows-amd64' ) ;
73
73
74
- this . _copyTemplate ( " module.json" , { repository : this . repository } ) ;
75
- this . _copyTemplate ( " package.json" , { name : this . name } )
74
+ this . _copyTemplate ( ' module.json' , { repository : this . repository } ) ;
75
+ this . _copyTemplate ( ' package.json' , { name : this . name } )
76
76
}
77
77
78
78
_copyStatic ( from , to = undefined ) {
0 commit comments