Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} else {
throw err;
}
});
const argv = minimist(process.argv.slice(2));
const tasks = argv._;
const binaryPath = process.env._;
const binaryName =
binaryPath && binaryPath.endsWith('/npx') ? 'npx mrm' : 'mrm';
// Custom config / tasks directory
if (argv.dir) {
const dir = path.resolve(argv.dir);
if (!isDirectory.sync(dir)) {
printError(`Directory “${dir}” not found.`);
process.exit(1);
}
directories.unshift(dir);
}
// Preset
const preset = argv.preset || 'default';
const isDefaultPreset = preset === 'default';
if (isDefaultPreset) {
directories.push(path.dirname(require.resolve('mrm-preset-default')));
} else {
const presetPath = tryResolve(`mrm-preset-${preset}`, preset);
if (!presetPath) {
printError(`Preset “${preset}” not found.
function searchImplementationFile(file) {
if (isDirectory.sync(file)) {
const dir = file;
const mainFile = join(dir, 'index.js');
if (existsSync(mainFile)) {
return mainFile;
}
} else {
if (existsSync(file)) {
return file;
}
const fileWithExtension = file + '.js';
if (existsSync(fileWithExtension)) {
return fileWithExtension;
}
}
return undefined;
}
getPath ( name, checkExistence = false ) {
const templatePath = path.join ( Config.directory, name );
return checkExistence ? isDirectory.sync ( templatePath ) && templatePath : templatePath;
},
static searchComponentFile(dirOrFile, {searchInPath = false} = {}) {
let dir;
if (isDirectory.sync(dirOrFile)) {
dir = dirOrFile;
} else if (existsSync(dirOrFile)) {
const file = dirOrFile;
const filename = basename(file);
if (
this.SUPPORTED_FILE_FORMATS.find(
format => filename === this.DEFAULT_FILE_NAME + '.' + format
)
) {
return file;
}
}
if (!dir) {
return undefined;
}
const load = function _load (path) {
try {
try {
const dep = require(path)
return dep
} catch (err) {
path = path.replace('./', '')
path = `${DIRPATH}/${path}`
if (isDirectory.sync(path)) {
path = path + '/index.js'
} else {
path = path + '.js'
}
logger(path, true)
let transform = babel.transformFileSync(path, babelConfig)
transform = transform.code.replace('exports.default', 'module.exports')
const pathElekid = (process.env.ELEKID_DEBUG) ? `${process.cwd()}/index.js` : 'elekid'
transform = `"use strict"; require = require('${pathElekid}').load; ${transform}`
const component = requireFromString(transform)
return component
}
} catch (err) {
filter: file => {
const relativeFile = relative(srcDir, file);
if (isDirectory.sync(file)) {
const targetDir = join(distDir, relativeFile);
emptyDirSync(targetDir);
return true;
}
const extension = extname(file);
if (!transpilableExtensions.includes(extension)) {
return true;
}
transpilableFiles.push(relativeFile);
return false;
}
});
fs.readFile(this.origin, (err, data) => {
if (!err) {
this.data = data;
if (isDirectory.sync(this.tempdir)) {
rimraf.sync(this.tempdir);
}
mkdirp(this.tempdir, (errd) => {
this.routeExtraction(errd, cb);
});
}
});
}