source: node_modules/@npmcli/fs/lib/mkdir/index.js@ 62b2964

finki-main main
Last change on this file since 62b2964 was 81bc7da, checked in by Klimentina Efremova <klimentina08642@…>, 3 months ago

Initial commit

  • Property mode set to 100644
File size: 981 bytes
Line 
1const fs = require('../fs.js')
2const getOptions = require('../common/get-options.js')
3const node = require('../common/node.js')
4const owner = require('../common/owner.js')
5
6const polyfill = require('./polyfill.js')
7
8// node 10.12.0 added the options parameter, which allows recursive and mode
9// properties to be passed
10const useNative = node.satisfies('>=10.12.0')
11
12// extends mkdir with the ability to specify an owner of the new dir
13const mkdir = async (path, opts) => {
14 const options = getOptions(opts, {
15 copy: ['mode', 'recursive', 'owner'],
16 wrap: 'mode',
17 })
18 const { uid, gid } = await owner.validate(path, options.owner)
19
20 // the polyfill is tested separately from this module, no need to hack
21 // process.version to try to trigger it just for coverage
22 // istanbul ignore next
23 const result = useNative
24 ? await fs.mkdir(path, options)
25 : await polyfill(path, options)
26
27 await owner.update(path, uid, gid)
28
29 return result
30}
31
32module.exports = mkdir
Note: See TracBrowser for help on using the repository browser.