Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
plugin.hidden = Boolean(options.hidden)
if (!strings.isBlank(name)) {
plugin.name = name
}
// directory check
if (filesystem.isNotDirectory(directory)) {
throw new Error(`Error: couldn't load plugin (not a directory): ${directory}`)
}
plugin.directory = directory
// the directory is the default name (unless we were told what it was)
if (strings.isBlank(name)) {
plugin.name = jetpack.inspect(directory).name
}
const jetpackPlugin = jetpack.cwd(plugin.directory)
// load any default commands passed in
plugin.commands = (options.preloadedCommands || []).map(loadCommandFromPreload)
// load the commands found in the commands sub-directory
const commandSearchDirectories = ['commands', 'build/commands']
commandSearchDirectories.map(dir => {
if (jetpackPlugin.exists(dir) === 'dir') {
const commands = jetpackPlugin.cwd(dir).find({ matching: commandFilePattern, recursive: true })
plugin.commands = plugin.commands.concat(
commands.map(file => loadCommandFromFile(path.join(directory, dir, file))),
)
plugin.hidden = Boolean(options.hidden)
if (!strings.isBlank(name)) {
plugin.name = name
}
// directory check
if (fs.isNotDirectory(directory)) {
throw new Error(`Error: couldn't load plugin (not a directory): ${directory}`)
}
plugin.directory = directory
// the directory is the default name (unless we were told what it was)
if (strings.isBlank(name)) {
plugin.name = jetpack.inspect(directory).name
}
const jetpackPlugin = jetpack.cwd(plugin.directory)
// load any default commands passed in
plugin.commands = map(loadCommandFromPreload, options.preloadedCommands || [])
// load the commands found in the commands sub-directory
if (jetpackPlugin.exists('commands') === 'dir') {
const commands = jetpackPlugin.cwd('commands').find({ matching: commandFilePattern, recursive: true })
plugin.commands = plugin.commands.concat(
map(file => loadCommandFromFile(`${directory}/commands/${file}`), commands),
)
}
files.forEach(function(file) {
if (fso.statSync(dir + '/' + file).isDirectory()) {
filelist = utils.walkDirectory(dir + '/' + file, filelist);
}
else {
if (!/(\.DS_Store|\.keep)/.test(file)) {
filelist.push(fs.inspect(dir + '/' + file, {times: true}));
}
}
});
this.watcher = fs.watch(args.rootDir, {recursive: true}, (rawEventType, filename) => {
if (!filename) {
return;
}
const info = jetpack.inspect(path.join(args.rootDir, filename));
let eventType = rawEventType;
if (!info && rawEventType === 'rename') {
eventType = 'delete';
} else if (info && info.type === 'file' && rawEventType === 'change') {
eventType = 'fileChange';
} else if (info && info.type === 'file' && rawEventType === 'rename') {
eventType = 'fileRename';
} else if (info && info.type === 'dir' && rawEventType === 'change') {
eventType = 'dirChange';
} else if (info && info.type === 'dir' && rawEventType === 'rename') {
eventType = 'dirRename';
} else {
eventType = 'unknown';
}
fh.getFileSize = function(filePath) {
return jetpack.inspect(filePath).size;
};
.map(folder => jetpack.inspect(folder))
.map(dir => ({ id: dir.name }));
overwrite: (src, dest) => {
if (
inspect(src.absolutePath, { checksum: 'md5' }).md5 !==
inspect(dest.absolutePath, { checksum: 'md5' }).md5
) {
const answer = prompt(`Replace ${src.name}? [y|n] `);
return answer.match(/(yes|yep|y|sure)/, 'i');
}
return true;
},
});
fh.getDateModified = function(filePath) {
return jetpack.inspect(filePath, {times: true}).modifyTime;
};