How to use the newGroup function from npmlog

Find comprehensive JavaScript npmlog.newGroup code examples handpicked from public code repositorys.

158
159
160
161
162
163
164
165
166
167

This adds a new `are-we-there-yet` stream tracker to the progress tracker. The
object returned has the `log[level]` methods but is otherwise an
`are-we-there-yet` `TrackerStream` object.

## log.newGroup(name, weight)

This adds a new `are-we-there-yet` tracker group to the progress tracker. The
object returned has the `log[level]` methods but is otherwise an
`are-we-there-yet` `TrackerGroup` object.
fork icon61
star icon0
watch icon21

+ 13 other calls in file

167
168
169
170
171
172
173
174
175
176
log.silly('inspect', 'argv', argv)
log.silly('inspect', 'things', things)

log.enableProgress()
Promise.map(things, f => {
  groups.set(basename(f), log.newGroup(f))
  return flac.scan({path: f}, groups)
})
.map(b => {
  b.flacTrack = Track.fromFLAC(b.metadata, b.path, b.stats)
fork icon1
star icon0
watch icon3

5
6
7
8
9
10
11
12
13
14
var Promise = require('./promise');

var MAX_PREFIX_LENGTH = 12;
var nrTrackers = 0;
var loggerMap = {};
var trackerGroup = log.newGroup();

function enOrDisAbleProgress() {
        if (nrTrackers > 0) {
                log.enableProgress();
fork icon1
star icon0
watch icon2

+ 3 other calls in file

40
41
42
43
44
45
46
47
48
49
  log.disableProgress()
  process.exit(0)
}

log.verbose('unpack', 'processing', files)
files.forEach(f => groups.set(f, log.newGroup('process: ' + f)))
return Promise.map(
  files,
  f => extractRelease(f, tmpdir, covers, groups),
  {concurrency: 2}
fork icon1
star icon0
watch icon3

30
31
32
33
34
35
36
37
38
39
  // starts progress bar
  if (this[_setProgress] && this[_progress].size === 0) {
    npmlog.enableProgress()
  }

  this[_progress].set(section, npmlog.newGroup(section))
} else if (!hasTracker && subsection !== null) {
  // 2. no parent tracker and subsection
  this[_onError](`Parent tracker "${section}" does not exist`)
} else if (!hasTracker || !hasSubtracker) {
fork icon0
star icon0
watch icon1

+ 20 other calls in file

516
517
518
519
520
521
522
523
524
525
526
    })
  }, function () {
    if (linkTodoList.length === 0) return cb()
    self.differences.length = 0
    Array.prototype.push.apply(self.differences, linkTodoList)
    diffTrees(self.currentTree, self.idealTree, self.differences, log.newGroup('d2'), cb)
  })
}


function isLinkable (pkg, cb) {
fork icon0
star icon0
watch icon0

195
196
197
198
199
200
201
202
203
204
// handle log.success()
log.addLevel("success", 3001, { fg: "green", bold: true });

// create logger that subclasses use
Object.defineProperty(this, "logger", {
  value: log.newGroup(this.name),
});

// emit all buffered logs at configured level and higher
log.resume();
fork icon0
star icon0
watch icon0

45
46
47
48
49
50
51
52
53
54
// requires fail if you replace the exports object, and we do, not in deps, but
// in a dep of it.
var recalculateMetadata = require('../install/deps.js').recalculateMetadata

readPackageTree(folder, pulseTillDone('pack:readTree:' + packageId(pkg), iferr(cb, function (tree) {
  var recalcGroup = log.newGroup('pack:recalc:' + packageId(pkg))
  recalculateMetadata(tree, recalcGroup, iferr(cb, function () {
    recalcGroup.finish()
    pack_(tarball, folder, tree, pkg, pulseTillDone('pack:' + packageId(pkg), cb))
  }))
fork icon0
star icon0
watch icon0

16
17
18
19
20
21
22
23
24
25
26
})


test('validate-tree', function (t) {
  log.disableProgress()
  var validateTree = require('../../lib/install/validate-tree.js')
  validateTree(idealTree, log.newGroup('validate'), function (er) {
    t.pass("we didn't crash")
    t.end()
  })
})
fork icon0
star icon0
watch icon0

352
353
354
355
356
357
358
359
360
361
362
    todo.push([this, this.readGlobalPackageData])
  } else {
    todo.push([this, this.readLocalPackageData])
  }
  todo.push(
    [this, this.normalizeTree, log.newGroup('normalizeTree')])
  chain(todo, cb)
}


Installer.prototype.loadIdealTree = function (cb) {
fork icon0
star icon0
watch icon0