Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new option log #154

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ This string will be appended to the end of the concatenated output. It is proces

_(Default processing options are explained in the [grunt.template.process][] documentation)_

#### log
Type: `Boolean`
Default: `true`

This will allow users to decide between grunt.log or grunt.verbose.

#### stripBanners
Type: `Boolean` `Object`
Default: `false`
Expand Down
7 changes: 6 additions & 1 deletion tasks/concat.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module.exports = function(grunt) {
separator: grunt.util.linefeed,
banner: '',
footer: '',
log: true,
stripBanners: false,
process: false,
sourceMap: false,
Expand Down Expand Up @@ -114,7 +115,11 @@ module.exports = function(grunt) {
grunt.file.write(f.dest, src);

// Print a success message.
grunt.verbose.write('File ' + chalk.cyan(f.dest) + ' created.');
if (options.log === true) {
grunt.log.writeln('File ' + chalk.cyan(f.dest) + ' created.');
} else {
grunt.verbose.write('File ' + chalk.cyan(f.dest) + ' created.');
}
});
});

Expand Down
18 changes: 14 additions & 4 deletions tasks/lib/sourcemap.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,16 +239,26 @@ exports.init = function(grunt) {
var newSourceMap = this.generator.toJSON();
// Return a string for inline use or write the map.
if (this.options.sourceMapStyle === 'inline') {
grunt.verbose.writeln(
'Source map for ' + chalk.cyan(this.files.dest) + ' inlined.'
);
if ( this.options.log === true ) {
grunt.log.writeln(
'Source map for ' + chalk.cyan(this.files.dest) + ' inlined.'
);
} else {
grunt.verbose.writeln(
'Source map for ' + chalk.cyan(this.files.dest) + ' inlined.'
);
}
return JSON.stringify(newSourceMap, null, '');
}
grunt.file.write(
this.dest,
JSON.stringify(newSourceMap, null, '')
);
grunt.verbose.writeln('Source map ' + chalk.cyan(this.dest) + ' created.');
if ( this.options.log === true ) {
grunt.log.writeln('Source map ' + chalk.cyan(this.dest) + ' created.');
} else {
grunt.verbose.writeln('Source map ' + chalk.cyan(this.dest) + ' created.');
}

};

Expand Down