Пример #1
0
var pacman = function(name, spec, cb) {
    var cache_dir = path.join(osenv.home(), '.npminstall');

    // TODO never cache '*' items
    // lookup latest version for * in registry?

    // cache ~##.##.## without the loading ~
    // This allows for exact pinned versions and ~ versions that match
    // to hit the same cache item
    if (spec && /^~\d+[.]\d+[.]\d+$/.test(spec)) {
        spec = spec.replace('~', '');
    }

    if (!fs.existsSync(cache_dir)) {
        fs.mkdirSync(cache_dir);
    }

    var key = crypto.createHash('md5')
        .update(name).update(spec)
        .digest('hex');

    var tarfile = path.join(cache_dir, key + '.tar.gz');

    if (fs.existsSync(tarfile)) {
        return cb(null, tarfile);
    }

    fetch(name, spec, {})
    .syphon(barrage(fs.createWriteStream(tarfile)))
    .wait(function(err) {
        cb(err, tarfile);
    });
}
Пример #2
0
 return new Promise(function (resolve, reject) {
   npm(name, spec)
     .on('error', reject)
     .pipe(unpack(dest, function (err) {
       if (err) reject(err);
       else resolve(dest);
     }))
 }).then(function () {
Пример #3
0
step('download codemirror', function (callback) {
  if (!completedCleanup) throw new Error('skipped because cleanup was unsucessful');
  npm('codemirror', '*').pipe(unpack(__dirname + '/src', callback));
  completedDownload = true;
}, '60 seconds');
Пример #4
0
step('cleanup', function (callback) {
  rimraf(__dirname + '/src');
  rimraf(__dirname + '/lib');
  mkdirp(__dirname + '/lib');
  npm('codemirror', '*').pipe(unpack(__dirname + '/src', callback));
}, '60 seconds');
Пример #5
0
step('download', function (callback) {
  npm('codemirror', '*').pipe(unpack(__dirname + '/src', callback));
}, '60 seconds');