2014-04-21 95 views
1

我想开发一个批处理文件,该文件运行很多类型为“phonegap local plugin add”的命令,以便在我想共享我的应用程序时自动执行Phonegap插件安装过程。如何制作Phonegap插件安装程序批处理文件?

我发现在Linux上开发了以下解决方案:

#!/usr/bin/env node 

//this hook installs all your plugins 

// add your plugins to this list--either 
// the identifier, the filesystem location 
// or the URL 
var pluginlist = [ 
    "org.apache.cordova.device", 
    "org.apache.cordova.device-motion", 
    "org.apache.cordova.device-orientation", 
    "org.apache.cordova.geolocation", 
    "https://github.com/chrisekelley/AppPreferences/" 
]; 

// no need to configure below 

var fs = require('fs'); 
var path = require('path'); 
var sys = require('sys') 
var exec = require('child_process').exec; 

function puts(error, stdout, stderr) { 
    sys.puts(stdout) 
} 

pluginlist.forEach(function(plug) { 
    exec("cordova plugin add " + plug, puts); 
}); 

我想开发一个Windows批处理文件的代码。有人能告诉我我该怎么做?

回答

1

从脚本POV这可能是接近:

@echo off 
for %%a in (
    "org.apache.cordova.device" 
    "org.apache.cordova.device-motion" 
    "org.apache.cordova.device-orientation" 
    "org.apache.cordova.geolocation" 
    "https://github.com/chrisekelley/AppPreferences/" 
) do cordova plugin add %%a 
+0

你人治...! – Rahnzo

+0

@axl只有在cordova是一个批处理文件的情况下,您才会尝试编辑,并且没有声明cordova是批处理文件。 '.exe'或'.com'文件不需要'call'命令。 – foxidrive

相关问题