我正致力于 Gulp构建流程以实现自动化。我已经创建了一个Gulp任务来创建签名的android APK。现在我想显示一个通知弹出窗口,以便我可以了解我的Android APK已经构建。
有没有办法在Gulp流程中显示原生弹出窗口?
我已经完成了研究,发现了node-notifier和 gulp-notify 模块,但两者都不适用于我。请帮忙
根据已发布的回答
我试过以下,但没有帮助......我没有收到通知。是否需要Windows Toaster支持...我正在使用 Windows 8.1 Pro 。
gulp.task('notifier', function(){
notify('Running from notifier task', 'Everything looks good');
});
function notify(title, message) {
// Load dependencies
var path = require('path');
var notifier = require('node-notifier');
var notifyOptions = {
title: title,
message: message,
//icon: path.join(__dirname, 'coulson.jpg'), // Absolute path (doesn't work on balloons)
sound: true, // Only Notification Center or Windows Toasters
wait: true // Wait with callback, until user action is taken against notification
};
// start notifier
notifier.notify(notifyOptions);
}
答案 0 :(得分:1)
试试这个:
确保通过再次运行安装来安装这些
安装强>
npm install path node-notifier --save-dev
<强>任务强>
gulp.task('notifier', function(){
notify('Running from notifier task', 'Everything looks good');
);
通知程序功能
function notify(title, message) {
// Load dependencies
var path = require('path');
var notifier = require('node-notifier');
var notifyOptions = {
title: title,
message: message,
icon: path.join(__dirname, 'coulson.jpg'), // Absolute path (doesn't work on balloons)
sound: true, // Only Notification Center or Windows Toasters
wait: true // Wait with callback, until user action is taken against notification
};
// start notifier
notifier.notify(notifyOptions);
}
答案 1 :(得分:0)
在提出问题后为时已晚,但我认为在这里记录我的解决方案很好。 因此,有不同的命令来显示针对不同操作系统的本机弹出窗口。
1。 Windows
使用命令msg * <Your_Message_Here>
,例如msg * Hello World
。
此弹出窗口在1分钟后自动关闭。
2.iOS
使用命令
osascript -e 'tell app \"System Events\" to display dialog \"<Your_Message>\" with title \"<Your_Title>\"'"
然后您可以使用节点exec
var WINDOWS_POPUP = "msg * MESSAGE";
var MAC_POPUP = "osascript -e 'tell app \"System Events\" to display dialog \"MESSAGE\" with title \"SUCCESS\"'";
function execCMD(cmd, cb) {
exec(cmd,
{
cwd: './',
maxBuffer: 2048 * 2048
},
function (err, stdout, stderr) {
plugins.util.log(stdout);
plugins.util.log(stderr);
if (err) {
cb(err);
} else {
cb(null,stdout);
}
});
}
/**
* Rename android apk
*/
gulp.task('copyAPK', function () {
return gulp.src(APK_PATH)
.pipe(plugins.if(args.signedAPK, plugins.rename(APK_NAME)))
.pipe(gulp.dest(releaseDirName + '/Android/'))
.on('end', function () {
plugins.util.log(plugins.util.colors.green('Good Job! Your APK is ready at following location : ') + plugins.util.colors.cyan(releaseDirName + '/Android/' + APK_NAME))
execCMD(WINDOWS_POPUP.replace('MESSAGE', 'Good Job! Your APK is ready at following location : ' + releaseDirName + '/Android/' + APK_NAME), function () {
})
});
});
/**
* Copy generated IPA
*/
gulp.task('copyIPA', function () {
return gulp.src(IPA_PATH)
.pipe(plugins.rename(IPA_NAME))
.pipe(gulp.dest(releaseDirName + '/iOS/'))
.on('end', function () {
plugins.util.log(plugins.util.colors.green('Good Job! Your IPA is ready at following location : ') + plugins.util.colors.cyan(releaseDirName + '/iOS/' + IPA_NAME))
execCMD(MAC_POPUP.replace('MESSAGE', 'Good Job! Your IPA is ready at following location : ' + releaseDirName + '/iOS/' + IPA_NAME), function () {
})
});
})
希望这会帮助脚本编写人员:)。