• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1const t = require('tap')
2if (!process.getuid || process.getuid() !== 0 || !process.env.SUDO_UID || !process.env.SUDO_GID) {
3  t.pass('this test only runs in sudo mode')
4  t.end()
5  process.exit(0)
6}
7
8const common = require('../common-tap.js')
9const fs = require('fs')
10const mkdirp = require('mkdirp')
11mkdirp.sync(common.cache + '/root/owned')
12fs.writeFileSync(common.cache + '/root/owned/file.txt', 'should be chowned')
13const chown = require('chownr')
14
15// this will fire after t.teardown() but before process.on('exit')
16setTimeout(() => {
17  chown.sync(common.cache, +process.env.SUDO_UID, +process.env.SUDO_GID)
18}, 100)
19
20t.pass('this is fine')
21