@@ -97,8 +97,8 @@ var class_name,
97
97
98
98
console . log ( 'NativeScript Plugin Seed Configuration' ) ;
99
99
100
- // Expected order: `gitHubUsername` `pluginName` `initGit` `includeTypescriptDemo ` `includeAngularDemo`
101
- // Example: gitHubUsername=PluginAuthor pluginName=myPluginClassName initGit=n includeTypescriptDemo =y includeAngularDemo=n
100
+ // Expected order: `gitHubUsername` `pluginName` `initGit` `includeTypeScriptDemo ` `includeAngularDemo`
101
+ // Example: gitHubUsername=PluginAuthor pluginName=myPluginClassName initGit=n includeTypeScriptDemo =y includeAngularDemo=n
102
102
var parseArgv = function ( ) {
103
103
var argv = Array . prototype . slice . call ( process . argv , 2 ) ;
104
104
var result = { } ;
@@ -115,11 +115,21 @@ if (argv) {
115
115
inputParams . github_username = argv . gitHubUsername ;
116
116
inputParams . plugin_name = argv . pluginName ;
117
117
inputParams . init_git = argv . initGit ;
118
- inputParams . include_typescript_demo = argv . includeTypescriptDemo ;
118
+ inputParams . include_typescript_demo = argv . includeTypeScriptDemo ;
119
119
inputParams . include_angular_demo = argv . includeAngularDemo ;
120
120
// inputParams.include_vue_demo = argv.includeVueDemo;
121
121
}
122
122
123
+ if ( ! isInteractive ( ) && ( ! inputParams . github_username || ! inputParams . plugin_name || ! inputParams . init_git || ! inputParams . include_typescript_demo || ! inputParams . include_angular_demo ) ) {
124
+ console . log ( "Using default values for plugin creation since your shell is not interactive." ) ;
125
+ inputParams . github_username = "PluginAuthor" ;
126
+ inputParams . plugin_name = "myPluginClassName" ;
127
+ inputParams . init_git = "y" ;
128
+ inputParams . include_typescript_demo = "y" ;
129
+ inputParams . include_angular_demo = "n" ;
130
+ // inputParams.include_vue_demo = "n";
131
+ }
132
+
123
133
askGithubUsername ( ) ;
124
134
125
135
function askGithubUsername ( ) {
@@ -197,7 +207,7 @@ function askAngularDemo() {
197
207
prompt . start ( ) ;
198
208
prompt . get ( {
199
209
name : 'include_angular_demo' ,
200
- description : 'Do you want to include a "Angular NativeScript" application linked with your plugin to make development easier (y/n)?' ,
210
+ description : 'Do you want to include an "Angular NativeScript" application linked with your plugin to make development easier (y/n)?' ,
201
211
default : 'n'
202
212
} , function ( err , result ) {
203
213
if ( err ) {
@@ -578,11 +588,6 @@ function askInitGit() {
578
588
}
579
589
}
580
590
581
- // todo
582
- function getTslintCommand ( appPath ) {
583
-
584
- }
585
-
586
591
function replaceFiles ( ) {
587
592
for ( key in filesToReplace ) {
588
593
var file = filesToReplace [ key ] ;
@@ -626,6 +631,30 @@ function addPluginToDemoApps() {
626
631
}
627
632
}
628
633
634
+ function isInteractive ( ) {
635
+ const result = isRunningInTTY ( ) && ! isCIEnvironment ( ) ;
636
+ return result ;
637
+ }
638
+
639
+ /**
640
+ * Checks if current process is running in Text Terminal (TTY)
641
+ */
642
+ function isRunningInTTY ( ) {
643
+ return process . stdout &&
644
+ process . stdout . isTTY &&
645
+ process . stdin &&
646
+ process . stdin . isTTY ;
647
+ }
648
+
649
+ function isCIEnvironment ( ) {
650
+ // The following CI environments set their own environment variables that we respect:
651
+ // travis: "CI",
652
+ // circleCI: "CI",
653
+ // jenkins: "JENKINS_HOME"
654
+
655
+ return ! ! ( process . env && ( process . env . CI || process . env . JENKINS_HOME ) ) ;
656
+ }
657
+
629
658
function initGit ( ) {
630
659
if ( inputParams . init_git && inputParams . init_git . toLowerCase ( ) === 'y' ) {
631
660
rimraf . sync ( '../.git' ) ;
0 commit comments