• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1const npm = require('../../lib/npm.js')
2const t = require('tap')
3
4const common = require('../common-tap.js')
5
6common.skipIfWindows('this is a unix-only thing')
7
8const errorMessage = require('../../lib/utils/error-message.js')
9
10t.plan(1)
11
12npm.load({ cache: common.cache }, () => {
13  npm.config.set('cache', common.cache)
14  const er = new Error('access is e, i am afraid')
15  er.code = 'EACCES'
16  er.errno = -13
17  er.path = common.cache + '/src'
18  er.dest = common.cache + '/to'
19
20  t.match(errorMessage(er), {
21    summary: [
22      [
23        '',
24        new RegExp('\n' +
25          'Your cache folder contains root-owned files, due to a bug in\n' +
26          'previous versions of npm which has since been addressed.\n' +
27          '\n' +
28          'To permanently fix this problem, please run:\n' +
29          '  sudo chown -R [0-9]+:[0-9]+ ".*npm_cache_cache-eacces-error-message"'
30        )
31      ]
32    ],
33    detail: []
34  }, 'get the helpful error message')
35})
36