简体   繁体   English

如何以编程方式运行grunt任务nodejs?

[英]how to run grunt task programmatically nodejs?

I need to use grunt-phonegap-build , I have used this method programmatically: 我需要使用grunt-phonegap-build ,我以编程方式使用了此方法:

grunt.loadNpmTasks('grunt-phonegap-build');  
  grunt.initConfig({
                "phonegap-build": {
                        debug: {
                              options: {
                                    archive:"myapp.zip",
                                   "appId":"567576",
                                   "user": {
                                        "email":******,
                                        "password":******
                                        },
                                    download:'dist/android.apk'         
                               }
                         }
                  }
                });
  grunt.tasks('phonegap-build', {}, function(args) {
     grunt.log.ok('Done running tasks.');
  });

Problem is executing repeat the same process and after "done running tasks". 问题是执行相同的过程并在“完成运行任务”之后执行。 Sometimes it executes one time. 有时它执行一次。 When I press the button call this function via ajax. 当我按下按钮时,通过ajax调用此功能。 I have no idea, can u please explain this? 我不知道,你能解释一下吗? How to solve this? 如何解决呢?

Terminal process: 终端过程:

  Running "phonegap-build:debug" (phonegap-build) task
>> Starting upload
>> Upload successful (HTTP 200)
>> Checking build status successful (HTTP 200)
>> Getting download location for ios successful (HTTP 302)
>> Downloading ios app
>> Checking build status successful (HTTP 200)
>> Checking build status successful (HTTP 200)
>> Downloaded ios app

Running "phonegap-build:debug" (phonegap-build) task
>> Starting upload
>> Checking build status successful (HTTP 200)
>> Checking build status successful (HTTP 200)
>> Upload successful (HTTP 200)
>> Checking build status successful (HTTP 200)
>> Getting download location for ios successful (HTTP 302)
>> Downloading android app
>> Checking build status successful (HTTP 200)
>> Checking build status successful (HTTP 200)
>> Downloaded android app

Done, without errors.

manually if i give grunt phonegap-build command in CLI. 如果我在CLI中给出grunt phonegap-build命令,请手动进行。 it it working fine. 它工作正常。 Can u help me? 你能帮我吗?

programmatically execution the grunt is not working properly 以编程方式执行咕unt声无法正常工作

Please create default task first and then call your custom phonegap task. 请先创建默认任务,然后调用自定义phonegap任务。

if you are doing same and i am not getting post your full gruntfile so i can run it here and 如果您正在做同样的事情,但我没有发布完整的gruntfile,那么我可以在这里运行它,并且

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM