我正在尝试根据Gruntfile.js
中的功能移动应用程序目录中的一些图标。有可能做这样的事情吗?我已经尝试了以下方法(进入开发或暂存文件夹并将所有文件复制到以前的目录),但无法使其工作。提前谢谢。
grunt.registerTask('setAppIcon', 'Task that sets the app icon', function(environment) {
if (environment.toLowerCase() == "development") {
grunt.task.run(['exec:command:cd app/lib/extras/res/icon/ios/dev && cp -a . ../']);
} else if (environment.toLowerCase() == "staging") {
grunt.task.run(['exec:command:cd app/lib/extras/res/icon/ios/staging && cp -a . ../']);
}
});
我找到了一个解决方案,我最终使用了shelljs。
我所要做的就是转到我的应用程序的根目录,运行以下 shell 命令以使用 npm 安装它: npm install -g shelljs
并修改我的脚本,使其如下所示
// Script to have environment specific icon
grunt.registerTask('setAppIcon', 'Task that sets the app icon', function() {
var env = grunt.option('env');
var shell = require('shelljs');
if (env.toLowerCase() === "development") {
shell.exec('cd app/lib/extras/res/icon/ios/dev && cp -a . ../');
} else if (env.toLowerCase() === "staging") {
shell.exec('cd app/lib/extras/res/icon/ios/staging && cp -a . ../');
} else if (env.toLowerCase() === "production") {
shell.exec('cd app/lib/extras/res/icon/ios/prod && cp -a . ../');
}
});