How to use the path.existsSync function in path

To help you get started, we’ve selected a few path examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github appcelerator / alloy / Alloy / commands / compile.js View on Github external
{
		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
github appcelerator / alloy / Alloy / commands / compile.js View on Github external
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)) {
github blackberry / BB10-Webworks-Packager / lib / file-manager.js View on Github external
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);
github irinc / ixf / build / build.js View on Github external
if(!path.existsSync(webDestDir + "/" + subdir))
		fs.mkdirSync(webDestDir + "/" + subdir);

	for(i=0; i
github blackberry / BB10-Webworks-Packager / build / build / pack.js View on Github external
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);
    }
}
github mozillaarchive / deuxdrop / servers / lib / rdservers / configurer.js View on Github external
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);
  }
}
github sapegin / sweet / swe.js View on Github external
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);
github mjackson / strata / lib / static.js View on Github external
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) {
github syntaxhighlighter / syntaxhighlighter / build / build.js View on Github external
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);
}