|
| 1 | +'use strict' |
| 2 | + |
| 3 | +const BB = require('bluebird') |
| 4 | +const fs = BB.promisifyAll(require('fs')) |
| 5 | +const mkdirp = BB.promisify(require('mkdirp')) |
| 6 | +const npmlog = require('npmlog') |
| 7 | +const path = require('path') |
| 8 | +const test = require('tap').test |
| 9 | + |
| 10 | +const testDir = require('./util/test-dir')(__filename) |
| 11 | + |
| 12 | +const extract = require('../extract.js') |
| 13 | + |
| 14 | +npmlog.level = process.env.LOGLEVEL || 'silent' |
| 15 | +const OPTS = { |
| 16 | + git: 'git', |
| 17 | + cache: path.join(testDir, 'cache'), |
| 18 | + log: npmlog, |
| 19 | + registry: 'https://my.mock.registry/', |
| 20 | + retry: false |
| 21 | +} |
| 22 | + |
| 23 | +test('extracting a git target reports failures', t => { |
| 24 | + const oldPath = process.env.PATH |
| 25 | + process.env.PATH = '' |
| 26 | + const dest = path.join(testDir, 'foo') |
| 27 | + return mkdirp(dest) |
| 28 | + .then(() => fs.writeFileAsync(path.join(dest, 'q'), 'foo')) |
| 29 | + .then(() => extract('github:zkat/pacote', dest, |
| 30 | + Object.assign({}, OPTS))) |
| 31 | + .finally(() => { |
| 32 | + process.env.PATH = oldPath |
| 33 | + }) |
| 34 | + .then(() => { |
| 35 | + t.fail('the promise should not have resolved') |
| 36 | + }, (err) => { |
| 37 | + // We're not testing the specific text of the error message. We just check |
| 38 | + // that it is an execution error. |
| 39 | + t.equal(err.code, 'ENOENT') |
| 40 | + }) |
| 41 | +}) |
0 commit comments