diff options
| author | Florian Dold <florian.dold@gmail.com> | 2019-03-27 21:01:33 +0100 |
|---|---|---|
| committer | Florian Dold <florian.dold@gmail.com> | 2019-03-27 21:01:33 +0100 |
| commit | cc97a4dd2a967e1c2273bd5f4c5f49a5bf2e2585 (patch) | |
| tree | 92c5d88706a6ffc654d1b133618d357890e7096b /node_modules/vinyl-fs/lib/prepareWrite.js | |
| parent | 3771b4d6b67b34c130f3a9a1a15f42deefdb2eda (diff) | |
remove node_modules
Diffstat (limited to 'node_modules/vinyl-fs/lib/prepareWrite.js')
| -rw-r--r-- | node_modules/vinyl-fs/lib/prepareWrite.js | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/node_modules/vinyl-fs/lib/prepareWrite.js b/node_modules/vinyl-fs/lib/prepareWrite.js deleted file mode 100644 index 50d86cd12..000000000 --- a/node_modules/vinyl-fs/lib/prepareWrite.js +++ /dev/null @@ -1,69 +0,0 @@ -'use strict'; - -var assign = require('object-assign'); -var path = require('path'); -var mkdirp = require('mkdirp'); -var fs = require('graceful-fs'); - -function booleanOrFunc(v, file) { - if (typeof v !== 'boolean' && typeof v !== 'function') { - return null; - } - - return typeof v === 'boolean' ? v : v(file); -} - -function stringOrFunc(v, file) { - if (typeof v !== 'string' && typeof v !== 'function') { - return null; - } - - return typeof v === 'string' ? v : v(file); -} - -function prepareWrite(outFolder, file, opt, cb) { - var options = assign({ - cwd: process.cwd(), - mode: (file.stat ? file.stat.mode : null), - dirMode: null, - overwrite: true, - }, opt); - var overwrite = booleanOrFunc(options.overwrite, file); - options.flag = (overwrite ? 'w' : 'wx'); - - var cwd = path.resolve(options.cwd); - var outFolderPath = stringOrFunc(outFolder, file); - if (!outFolderPath) { - throw new Error('Invalid output folder'); - } - var basePath = options.base ? - stringOrFunc(options.base, file) : path.resolve(cwd, outFolderPath); - if (!basePath) { - throw new Error('Invalid base option'); - } - - var writePath = path.resolve(basePath, file.relative); - var writeFolder = path.dirname(writePath); - - // Wire up new properties - file.stat = (file.stat || new fs.Stats()); - file.stat.mode = options.mode; - file.flag = options.flag; - file.cwd = cwd; - file.base = basePath; - file.path = writePath; - - // Mkdirp the folder the file is going in - var mkdirpOpts = { - mode: options.dirMode, - fs: fs, - }; - mkdirp(writeFolder, mkdirpOpts, function(err) { - if (err) { - return cb(err); - } - cb(null, writePath); - }); -} - -module.exports = prepareWrite; |
