source: trip-planner-front/node_modules/mkdirp/lib/opts-arg.js@ 59329aa

Last change on this file since 59329aa was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 784 bytes
Line 
1const { promisify } = require('util')
2const fs = require('fs')
3const optsArg = opts => {
4 if (!opts)
5 opts = { mode: 0o777, fs }
6 else if (typeof opts === 'object')
7 opts = { mode: 0o777, fs, ...opts }
8 else if (typeof opts === 'number')
9 opts = { mode: opts, fs }
10 else if (typeof opts === 'string')
11 opts = { mode: parseInt(opts, 8), fs }
12 else
13 throw new TypeError('invalid options argument')
14
15 opts.mkdir = opts.mkdir || opts.fs.mkdir || fs.mkdir
16 opts.mkdirAsync = promisify(opts.mkdir)
17 opts.stat = opts.stat || opts.fs.stat || fs.stat
18 opts.statAsync = promisify(opts.stat)
19 opts.statSync = opts.statSync || opts.fs.statSync || fs.statSync
20 opts.mkdirSync = opts.mkdirSync || opts.fs.mkdirSync || fs.mkdirSync
21 return opts
22}
23module.exports = optsArg
Note: See TracBrowser for help on using the repository browser.