How to use the log function from grunt

Find comprehensive JavaScript grunt.log code examples handpicked from public code repositorys.

80
81
82
83
84
85
86
87
88
89
if (loadPath !== '' &&
    !grunt.util._.contains(this.filesLoadedSoFar, loadPath) &&
    !grunt.util._.contains(this.beingLoaded, loadPath)) {
  currentDepth.push(" ");
  if (this.printDepGraph) {
    grunt.log.writeln(currentDepth.join("") + className);
  }
  this.beingLoaded.push(loadPath);
  try {
      eval(grunt.file.read(loadPath));
fork icon21
star icon0
watch icon2

+ 5 other calls in file

13
14
15
16
17
18
19
20
21

// Draw the help screen.
function displayHelp(withFlags) {
  var pkg = require(path.normalize(__dirname + '/../package.json'));
  grunt.log.writeln();
  grunt.log.writeln(template('<%= _.capitalize(name).blue.inverse %> - version: <%= version %> - <%= description %>', pkg));

  var col1len = 1;
  var widths;
fork icon7
star icon10
watch icon5

+ 11 other calls in file

191
192
193
194
195
196
197
198
199
200
// Log this.file src and dest properties when --verbose is specified.
if (grunt.option('verbose')) {
  files.forEach(function(obj) {
    var output = [];
    if ('src' in obj) {
      output.push(obj.src.length > 0 ? grunt.log.wordlist(obj.src) : '[no src]'.yellow);
    }
    if ('dest' in obj) {
      output.push('-> ' + (obj.dest ? String(obj.dest).cyan : '[no dest]'.yellow));
    }
fork icon3
star icon0
watch icon0

+ 5 other calls in file

35
36
37
38
39
40
41
42
43
44
// Draw the help screen.
function displayHelp() {
  var pkg = require(__dirname + "/../package.json");
  grunt.log.writeln();
  grunt.log.writeln(pkg.description);
  grunt.log.writeln((" " + pkg.name + " ").green.inverse
    + " Version - " + pkg.version);

  // Borrowed heavily from the Grunt help source.
  var col1len = 0;
fork icon0
star icon4
watch icon2

+ 13 other calls in file

24
25
26
27
28
29
30
31
32
33
if (!helpers.is(bowerJSON, 'object') && grunt.file.isFile(configFile)) {
  bowerJSON = grunt.file.readJSON(configFile);

  if (configFile !== 'bower.json') {
    grunt.log.writeln();
    grunt.log.warn(configFile.yellow + ' is deprecated.'.yellow);
    grunt.log.writeln('Your dependencies are going to be managed in "bower.json" going forward. Everything will carry over. :)'.cyan);
    grunt.log.writeln();
  }
}
fork icon87
star icon0
watch icon1

+ 13 other calls in file

72
73
74
75
76
77
78
79
80
81
  'footer',
];

// Header
grunt.help.header = function() {
  grunt.log.writeln('grunt-init: Generate project scaffolding from a template. (v' + pkg.version + ')');
};

// Usage info.
grunt.help.usage = function() {
fork icon71
star icon191
watch icon0

+ 13 other calls in file

12
13
14
15
16
17
18
19
20
21
  }
});

// Register your own tasks
grunt.registerTask('mytask', function() {
  grunt.log.write('Ran my task.');
});

// Load tasks from npm
grunt.loadNpmTasks('grunt-contrib-jasmine');
fork icon25
star icon0
watch icon0

+ 3 other calls in file

70
71
72
73
74
75
76
77
78
79
);
child.stdout.on('data', function (d) {
  grunt.log.write(d);
});
child.stderr.on('data', function (d) {
  grunt.log.error(d);
});
child.on('close', function (code) {
  if (opt.verbose) {
    grunt.log.ok('[grunt-gulp] Done running Grunt "' + name + '" task.');
fork icon22
star icon167
watch icon4

+ 5 other calls in file

21
22
23
24
25
26
27
28
29
30
};

// overwrite helper's logging methods
cHelpers.log = {
  warn: function(msg) { localGrunt.log.warn(msg); },
  info: function(msg) { localGrunt.log.writeln(msg); },
  error: function(msg) { localGrunt.log.error(msg); },
  debug: function(debug, msg) {
    if ( !debug ) return;
    localGrunt.log.writeln( 'debug :: '.blue + msg );
fork icon21
star icon95
watch icon6

+ 7 other calls in file

48
49
50
51
52
53
54
55
56
57
// Append a last function to kill spawnGrunt
runs.push(function() { spawnGrunt.kill('SIGINT'); });

// After watch starts waiting, run our commands then exit
spawnGrunt.stdout.on('data', function(data) {
  data = grunt.log.uncolor(String(data));
  out += data;

  // If we should run the next function
  var shouldRun = true;
fork icon9
star icon60
watch icon6

123
124
125
126
127
128
129
130
131
data[tag] = data[tag] || [];
var content = '';

$(tag).map(function(i, element) {
  console.log($(this));
  grunt.log.ok('element:'.yellow, tag);

  var text = $(this).text();
  var html = $(this).html();
fork icon2
star icon4
watch icon7

+ 11 other calls in file

4
5
6
7
8
9
10
11
12
13
    bar: 'Hello Grunt',
  }
});

grunt.registerMultiTask('log', 'Log stuff.', function() {
  grunt.log.writeln(this.data);
});


grunt.registerTask('test', ['log']);
fork icon1
star icon7
watch icon4

53
54
55
56
57
58
59
60
61
    // solve dest path, write output
    let destPath = join(destdir, getOutputFilename(path,type))
    grunt.file.write(destPath, toBuffer(output))

    // output information
    grunt.log.writeln(basename(path)+' => '+type+' '
        +chalk.green(stripped.glyf.length)+' glyphs, '
        +chalk.green(output.byteLength)+' bytes')
} )
fork icon1
star icon2
watch icon2

49
50
51
52
53
54
55
56
57
58
var cwd = process.cwd()

// Load all the required grunt task plugins. Requires first changing to here
// and then changing back after the tasks are run. Since grunt doesn't report
// when it can't load something, "spy" on its error
var err = grunt.log.error
var missing = []
grunt.log.error = function (msg) {
  var match = /Local Npm module "([a-zA-Z0-9-_@/]+)" not found/.exec(msg)
  if (match) {
fork icon1
star icon0
watch icon11

+ 3 other calls in file

30
31
32
33
34
35
36
37
38
39
bowerUpdate(options.update)
.on('log', function(result) {
    grunt.log.writeln(['bower', result.id.cyan, result.message].join(' '));
})
.on('error', function(error) {
    grunt.log.writeln(error);
    done(false);
})
.on('end', function(updated) {
    done();
fork icon2
star icon0
watch icon2

+ 5 other calls in file

38
39
40
41
42
43
44
45
46
47
48
49
  version = semver.inc(version, release)
  grunt.log.writeln('Updated package version: ' + version)
  writePackageVersion(version)
  grunt.log.writeln('Done updating the package version')
  updateLibraryFiles(version)
  grunt.log.writeln('Done updating the library files')
}




function readPackageVersion() {
fork icon0
star icon1
watch icon0

+ 4 other calls in file

208
209
210
211
212
213
214
215
216
217
if (grunt.option('angular')) {
  if (grunt.option('angular') === 'latest') {
    versions = [util.latestAngular()];
  }

  grunt.log.writeln("Using angular " + grunt.util.pluralize(versions, "version/versions") + ": " + versions.join(', '));
}

versions.forEach(function (version) {
  // .. then create a karma config for it!
fork icon0
star icon1
watch icon0

+ 9 other calls in file

18
19
20
21
22
23
24
25
26
27
    grunt.log.error("Failed comparison to stock example.");
    grunt.log.error("If these changes are intentional, please run `grunt update-stock-example` to overwrite the fixture.");
    if (showDiff) {
        grunt.log.writeln("\n" + diffs + "\n");
    } else {
        grunt.log.error("Run `grunt test-stock-example:diff` to see differences.");
    }
} else {
    grunt.log.writeln("Passed comparison to stock example.");
    passed = true;
fork icon0
star icon0
watch icon0

+ 6 other calls in file

175
176
177
178
179
180
181
182
183
184
if (file) {
    config.files = [file];
}

log = function (message) {
    grunt.log.writeln(message);
};

warn = function (message) {
    if (config.failIfVulnerabilitiesFound) {
fork icon0
star icon0
watch icon3

+ 15 other calls in file

17
18
19
20
21
22
23
24
25
26
}

assert.strictEqual(typeof opts, 'object');
assert.strictEqual(typeof callback, 'function');

grunt.log.writeln('> ' + cmd + ' ' + args.join(' '));

// var proc =
spawn({
  cmd: cmd,
fork icon0
star icon0
watch icon2

+ 7 other calls in file