Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function forcelink(src, dest, options, callback) {
if (!options || !options.cache) throw new Error('options.cache not defined!');
if (!callback) throw new Error('callback not defined!');
// uses relative path if linking to cache dir
if (path.relative) {
src = path.relative(options.cache, dest).slice(0, 2) !== '..' ? path.relative(path.dirname(dest), src) : src;
}
fs.lstat(dest, function(err, stat) {
// Error.
if (err && err.code !== 'ENOENT') {
return callback(err);
}
// Path does not exist. Symlink.
if (err && err.code === 'ENOENT') {
if (env == 'development') console.error("[millstone] linking '" + dest + "' -> '" + src + "'");
return fs.symlink(src, dest, callback);
}
// Path exists and is not a symlink. Do nothing.
if (!stat.isSymbolicLink()) {
if (env == 'development') console.error("[millstone] skipping re-linking '" + src + "' because '" + dest + " is already an existing file");
_getBundleStatusMessage(_ref, phase) {
let _ref$bundleDetails = _ref.bundleDetails,
entryFile = _ref$bundleDetails.entryFile,
platform = _ref$bundleDetails.platform,
dev = _ref$bundleDetails.dev,
minify = _ref$bundleDetails.minify,
bundleType = _ref$bundleDetails.bundleType,
transformedFileCount = _ref.transformedFileCount,
totalFileCount = _ref.totalFileCount,
ratio = _ref.ratio;
const localPath = path.relative(".", entryFile);
const fileName = path.basename(localPath);
const dirName = path.dirname(localPath);
platform = platform ? platform + ", " : "";
const devOrProd = dev ? "dev" : "prod";
const min = minify ? ", minified" : "";
const progress = (100 * ratio).toFixed(1);
const currentPhase =
phase === "done" ? ", done." : phase === "failed" ? ", failed." : "";
const filledBar = Math.floor(ratio * MAX_PROGRESS_BAR_CHAR_WIDTH);
return (
chalk.inverse.green.bold(` ${bundleType.toUpperCase()} `) +
chalk.dim(` [${platform}${devOrProd}${min}] ${dirName}/`) +
chalk.bold(fileName) +
" " +
chalk.green.bgGreen(DARK_BLOCK_CHAR.repeat(filledBar)) +
chalk.bgWhite.white(
watcher.on('all', async (event, filePath) => {
const start = new Date();
const src = path.relative('./', filePath);
const dist = path.join(
this.resolveDist('build/'),
src.startsWith('src') ? path.relative('src', src) : src,
);
switch (event) {
case 'add':
case 'change':
await makeDir(path.dirname(dist));
await copyFile(filePath, dist);
break;
case 'unlink':
case 'unlinkDir':
cleanDir(dist, { nosort: true, dot: true });
break;
default:
return;
}
const end = new Date();
const time = end.getTime() - start.getTime();
devtoolModuleFilenameTemplate: info =>
path.relative(paths.appSrc, info.absoluteResourcePath).replace(/\\/g, '/')
},
fat: {},
uat: {},
prod: {}
}
};
var cwd = process.cwd();
var rootPath = path.join(path.dirname(__filename), "../../../");
var pomyConfig = path.join(rootPath, "pomy.json");
if (fs.existsSync(pomyConfig)) {
global.settings = config(path.relative(cwd, pomyConfig));
} else {
rootPath = path.join(path.dirname(__filename), "../");
pomyConfig = path.join(rootPath, "pomy.json");
global.settings = config(path.relative(cwd, pomyConfig));
}
global.settings.paths = {
cwd: cwd,
root: rootPath
};
var argvs = minimist(process.argv.slice(2));
var name = global.settings.name;
var target = argvs.target || global.settings.target || 'local';
var debug = !!(argvs.debug || global.settings.debug);
var dSite = global.settings.deploy[target];
var ips = dSite.ips;
var ip = argvs.ip || (ips.length > 0 ? ips[0] : null) || '127.0.0.1';
const toSizes = modules => {
let sizes = {}
for (let { id, size } of modules) {
let cwd = path.dirname(id)
let { pkg, path: pkgPath } = readPkgUp.sync({ cwd })
let [name, relPath] = pkg !== null
? [pkg.name, path.relative(path.dirname(pkgPath), id)]
: ['(unknown)', id]
sizes[name] = sizes[name] || []
sizes[name][relPath] = size
}
return sizes
}
return store.getUniqueFileName(store, image, image.targetDir).then(function (targetFilename) {
image.newPath = (config.paths.subdir + '/' +
config.paths.imagesRelPath + '/' + path.relative(config.paths.imagesPath, targetFilename))
.replace(new RegExp('\\' + path.sep, 'g'), '/');
return image;
});
});
function to_rel_path (abs_path) {
return to_unix_path(path.relative(fl.base_path, abs_path));
}
files.forEach((file) => {
const fullPath = path.join(dirPath, file);
stats = fs.lstatSync(fullPath);
if (stats.isDirectory()) {
list = list.concat(this.recursiveReaddirSync(fullPath, rootDir));
} else {
list.push({
path: path.relative(rootDir, fullPath),
size: filesize(stats.size),
fullPath,
statsSize: stats.size,
});
}
});
list = list.sort((a, b) => {