我需要把git日志放到一个文件里。命令行工作正常
Git log command line result
但是,如果我使用shelljs.exec调用这个带有grunt任务的命令,我不会得到任何输出
Git log with grunt task using shelljs.exec
下面是grunt代码:
/*global module:false,require,console*/
'use strict';
var shell = require('shelljs');
module.exports = function (grunt) {
// Project configuration.
grunt.initConfig({
// Task configuration.
});
grunt.task.registerTask('git-log', 'git log output', function () {
console.log('RESULT : ', shell.exec('git log HEAD...HEAD^ --oneline',{silent : true}).output);
});
// Default task.
grunt.registerTask('default', ['git-log']);
};我检查了所有的shelljs文档,并尝试了不同的方法(包括异步),但都没有成功...
有什么想法吗?Thx
发布于 2016-06-17 21:01:51
尝试使用.stdout而不是.output。
在你的代码中:
shell.exec(
'git log HEAD...HEAD^ --oneline',
{silent : true}
).output;更改为:
shell.exec(
'git log HEAD...HEAD^ --oneline',
{silent : true}
).stdout;https://stackoverflow.com/questions/35062484
复制相似问题