I'm new to Gulp (or Grunt) tools. I created a function to print out the version
value in my package.json
file, like this
const {dest, parallel, series, src } = require('gulp');
const semver = require('semver');
const package_json = path.join(path.dirname(__filename),'package.json');
const pkg = JSON.parse(fs.readFileSync(package_json));
const version = semver.parse(pkg.version);
function get_version(cb) {
console.log(version.version);
cb();
}
exports.get_version = get_version
and I get
$ gulp get_version -f gulpfile-version.js
[16:07:08] Using gulpfile ~/some_path/gulpfile-version.js
[16:07:08] Starting 'get_version'...
1.4.6
[16:07:08] Finished 'get_version' after 1.91 ms
How can I modify my function to be less verbose and only print out the 1.4.6
string, and not the other time-stamped lines?
You can use --silent
flag in your command to suppress the gulp logs. Refer the doc https://github.com/gulpjs/gulp/blob/master/docs/CLI.md
Your example
$ gulp get_version -f gulpfile-version.js --silent
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.