mirror of
https://github.com/S2-/minifyfromhtml.git
synced 2025-08-03 20:30:04 +02:00
add some babel stuff
This commit is contained in:
45
node_modules/resolve/lib/node-modules-paths.js
generated
vendored
Normal file
45
node_modules/resolve/lib/node-modules-paths.js
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
var parse = path.parse || require('path-parse');
|
||||
|
||||
module.exports = function nodeModulesPaths(start, opts) {
|
||||
var modules = opts && opts.moduleDirectory
|
||||
? [].concat(opts.moduleDirectory)
|
||||
: ['node_modules'];
|
||||
|
||||
// ensure that `start` is an absolute path at this point,
|
||||
// resolving against the process' current working directory
|
||||
var absoluteStart = path.resolve(start);
|
||||
|
||||
if (opts && opts.preserveSymlinks === false) {
|
||||
try {
|
||||
absoluteStart = fs.realpathSync(absoluteStart);
|
||||
} catch (err) {
|
||||
if (err.code !== 'ENOENT') {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var prefix = '/';
|
||||
if (/^([A-Za-z]:)/.test(absoluteStart)) {
|
||||
prefix = '';
|
||||
} else if (/^\\\\/.test(absoluteStart)) {
|
||||
prefix = '\\\\';
|
||||
}
|
||||
|
||||
var paths = [absoluteStart];
|
||||
var parsed = parse(absoluteStart);
|
||||
while (parsed.dir !== paths[paths.length - 1]) {
|
||||
paths.push(parsed.dir);
|
||||
parsed = parse(parsed.dir);
|
||||
}
|
||||
|
||||
var dirs = paths.reduce(function (dirs, aPath) {
|
||||
return dirs.concat(modules.map(function (moduleDir) {
|
||||
return path.join(prefix, aPath, moduleDir);
|
||||
}));
|
||||
}, []);
|
||||
|
||||
return opts && opts.paths ? dirs.concat(opts.paths) : dirs;
|
||||
};
|
Reference in New Issue
Block a user