Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function parseGlobs (args, parsed) {
let patterns = [];
if (parsed.globIndex === -1 && globby.hasMagic(args[0])) {
while (args[0] && args[0][0] !== "-") {
// We found an entry file glob pattern
let pattern = args.shift();
patterns.push(pattern);
// Set the baseDir, if not already set
parsed.baseDir = parsed.baseDir || helpers.getBaseDir(pattern);
}
if (patterns.length) {
// We found entry file(s), so set the glob index and create the glob function
parsed.globIndex = parsed.args.length;
parsed.args.push((options) => {
return globby.sync(patterns, options);
});
}
async function strictGlobMatch(file: string, options: object): Promise {
let matches = await globby(file, options);
if (matches.length === 0) {
if (hasMagic(file)) {
throw new Error(`Could not find any files matching "${file}".`);
}
else {
throw new Error(`Could not find file: ${file}.`);
}
}
// Return files in a predictable order
return matches.sort();
}
cfg.plugins.use('autoinstall', require('@rollup/plugin-auto-install'), [{}])
}
// if (['umd', 'iife'].includes(cfg.output.format)) {
cfg.plugins
.use('node-resolve', require('rollup-plugin-node-resolve'), [{
main: false,
module: true,
jsnext: true,
extensions: ['.js', '.json'],
preferBuiltIns: true,
browser: true
}])
// }
if (globby.hasMagic(cfg.input)) {
cfg.plugins.use('multi-entry', require('rollup-plugin-multi-entry'), [])
}
}
},
items = sort(await map(items, (item) => {
if (globby.hasMagic(item)) {
return globby(item);
} else if (!!path.extname(item)) {
return item;
}
return globby(path.join(item, '*'));
}));
if (items.length) {
static async initialize(baseFn: string[], themes: Theme[] = []) {
const fn = [...baseFn, ...themes.map(t => t.filename)]
const found = await ThemeSet.findPath(fn)
const fnForWatch: Set = new Set(found.map(f => path.resolve(f)))
for (const f of fn) {
if (!hasMagic(f)) {
try {
const stat: fs.Stats = await lstat(f)
if (stat.isFile() || stat.isDirectory() || stat.isSymbolicLink())
fnForWatch.add(path.resolve(f))
} catch (e) {}
}
}
const instance = new ThemeSet({ fn, fnForWatch: [...fnForWatch] })
for (const f of found) await instance.load(f)
themes.forEach(t => instance.add(t))
return instance
}
function getFileArray(files) {
files = files.map(f => {
return f.replace(/\[/g, '\\[').replace(/\]/g, '\\]');
});
if (globby.hasMagic(files)) {
files = globby.sync(files);
}
return files;
}
case '--help':
return { kind: 'help' };
case '--version':
return { kind: 'version' };
case '-d':
case '--dry':
config.dry(true);
break;
default:
if (arg[0] === '-') {
throw new Error(`unexpected option: ${arg}`);
} else {
if (hasGlob(arg)) {
config.addSourcePaths(...globSync(arg));
} else {
config.addSourcePath(arg);
}
}
break;
}
}
return {
kind: 'run',
config: config.build()
};
}
}
const configFile = options.configFile;
const configOverrides = options.configOverrides;
const globbyOptions = options.globbyOptions;
const files = options.files;
const isCodeNotFile = code !== undefined;
if (!files || files.length !== 1 || isCodeNotFile) {
return Promise.reject(
new Error('The --print-config option must be used with exactly one file path.'),
);
}
const filePath = files[0];
if (globby.hasMagic(filePath)) {
return Promise.reject(new Error('The --print-config option does not support globs.'));
}
const stylelint = createStylelint({
config,
configFile,
configBasedir,
configOverrides,
});
const cwd = _.get(globbyOptions, 'cwd', process.cwd());
const absoluteFilePath = !path.isAbsolute(filePath)
? path.join(cwd, filePath)
: path.normalize(filePath);
const configSearchPath = stylelint._options.configFile || absoluteFilePath;
assets.forEach(asset =>
asset.filepath && globby.hasMagic(asset.filepath)
? globbyAssets.push(asset)
: normalAssets.push(asset),
);