Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
{
alloyConfig: alloyConfig,
home: path.resolve(inputPath),
projectDir : path.resolve(outputPath),
viewsDir: path.resolve(viewsDir),
controllersDir: path.resolve(controllersDir),
widgetsDir: path.resolve(widgetsDir),
modelsDir: path.resolve(modelsDir),
migrationsDir: path.resolve(migrationsDir),
resourcesDir: path.resolve(resourcesDir),
assetsDir: path.resolve(assetsDir),
configDir:path.resolve(configDir)
};
var alloyJMK = path.resolve(path.normalize(path.join(inputPath,"alloy.jmk")));
if (path.existsSync(alloyJMK))
{
logger.info("Found project specific makefile at " + "app/alloy.jmk".yellow);
var vm = require('vm'),
util = require('util');
var script = vm.createScript(fs.readFileSync(alloyJMK), 'alloy.jmk');
try
{
script.runInNewContext(compilerMakeFile);
}
catch(E)
{
logger.error("project build at "+alloyJMK.yellow + " generated an error during load: "+E.red);
}
}
// trigger our custom compiler makefile
function compile(args, program) {
var inputPath = args.length > 0 ? args[0] : U.resolveAppHome();
var alloyCF = path.join(inputPath,'config','alloy.json');
var generatedCFG = '';
var alloyConfig = {};
if (!path.existsSync(inputPath)) {
U.die('inputPath "' + inputPath + '" does not exist');
}
if (!program.outputPath)
{
var t = path.join(inputPath,'views','index.xml');
if (path.existsSync(t))
{
outputPath = path.join(inputPath,'..');
}
}
outputPath = outputPath ? outputPath : (program.outputPath || path.join(U.resolveAppHome(),".."));
U.ensureDir(outputPath);
// construct compiler config from alloy.json and the command line config parameters
if (path.existsSync(alloyCF)) {
function prepare(session) {
var conf = session.conf,
dest = session.sourcePaths,
webworksJsFiles;
if (path.existsSync(session.sourceDir)) {
wrench.rmdirSyncRecursive(session.sourceDir);
}
if (!path.existsSync(dest.CHROME)) {
wrench.mkdirSyncRecursive(dest.CHROME, "0755");
}
// copy bootstrap as well as ui.html file
wrench.copyDirSyncRecursive(conf.DEPENDENCIES_BOOTSTRAP, dest.CHROME);
if (!path.existsSync(dest.LIB)) {
wrench.mkdirSyncRecursive(dest.LIB, "0755");
}
// copy framework
wrench.copyDirSyncRecursive(conf.LIB, dest.LIB);
if(!path.existsSync(webDestDir + "/" + subdir))
fs.mkdirSync(webDestDir + "/" + subdir);
for(i=0; i
function copyFolder(source, destination) {
if (path.existsSync(source)) {
//create the destination folder if it does not exist
if (!path.existsSync(destination)) {
wrench.mkdirSyncRecursive(destination, "0755");
}
wrench.copyDirSyncRecursive(source, destination);
}
}
function makedirTree(path, mode) {
var tomake = [path];
path = $path.dirname(path);
while (!$path.existsSync(path)) {
tomake.push(path);
path = $path.dirname(path);
}
while (tomake.length) {
$fs.mkdirSync(tomake.pop(), mode);
}
}
function combine(options) {
var inputFiles = options.in,
resultFile = options.out,
filePreprocessor = options.filePreprocessor,
resultMtime = 0;
if (path.existsSync(resultFile)) {
resultMtime = fs.statSync(resultFile).mtime.getTime();
}
var updated = false,
filesContent = [];
for (var fileIdx = 0, filesCnt = inputFiles.length; fileIdx < filesCnt; fileIdx++) {
var file = inputFiles[fileIdx];
if (!path.existsSync(file)) {
error('Cannot find file ' + file + ' listed in your config.');
}
if (fs.statSync(file).mtime.getTime() > resultMtime) {
updated = true;
}
var contents = readUtfFile(file);
module.exports = function (app, root, index) {
if (typeof root != "string") {
throw new errors.Error("Invalid root directory");
}
if (path.existsSync(root)) {
var stats = fs.statSync(root);
if (!stats.isDirectory()) {
throw new errors.Error('"' + root + '" is not a directory')
}
} else {
throw new errors.Error('Directory "' + root + '" does not exist');
}
if (index && typeof index == "string") {
index = [index];
}
return function stat(env, callback) {
var fullPath = path.join(root, env.pathInfo);
path.exists(fullPath, function (exists) {
function rmdir(dir)
{
if(!path.existsSync(dir))
return;
glob(dir, '**').reverse().forEach(function(file)
{
file = path.join(dir, file);
try { fs.unlinkSync(file); }
catch(e) { fs.rmdirSync(file); }
});
fs.rmdirSync(dir);
}