首页 > 解决方案 > 如何在 Gulp 4 中运行 shell 脚本(.sh 文件)?

问题描述

大家好,新年快乐!

从 Gulp 版本 4 开始,我无法运行 shell 脚本。

我有简单的 shell 脚本。

if application id "com.adobe.estoolkit-4.0" is running then
    display dialog "Close The App!" buttons {"OK"} default button 1
end if

当我以这种方式运行它时,它可以工作

const { exec } = require('child_process');

function checkAppisOpen() {
    return exec('./utils/check.sh');
};

exports.run = checkAppisOpen;

但是当我尝试使用 npm gulp-shell 插件时,它不会工作。

错误:您是否忘记发出异步完成信号?

见代码:

const shell = require('gulp-shell');

function checkAppisOpen() {
    return shell('./utils/check.sh');
};

exports.run = checkAppisOpen;

我知道我做错了什么。请有人解释一下这个异步完成是如何在幕后工作的。或者至少在我可以读到它的地方。因为似乎 gulp 文档对我来说还不够https://gulpjs.com/docs/en/getting-started/async-completion

标签: shellgulpexecgulp-4gulp-shell

解决方案


推荐阅读