How to use file - 10 common examples

To help you get started, we’ve selected a few file 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 taboca / Chromeless-Standalone-Text-Editor-with-Ace / src / index.js View on Github external
fp.show(function(x) {
        // Check if the user selected nothing.
        if (!x) {
            return;
        }
        console.log("you picked " + x.length + " files");
        for (var i = 0; i < x.length; i++) {
            currentFile = "" + x[i];
            stringData = require("file").read(currentFile);
            editorSession.setValue(stringData);
        }
    });
}
github mozilla / chromeless / packages / addon-kit / lib / localization.js View on Github external
updateMemory: function() {
    let path = getStoragePath();
    // update storage if the file
    // does not exist or is older than we want
    if (!file.exists(path) ||
        (getUnixTimeStamp()-
         getLastModificationTime(path)/1000>=STORAGE_UPDATE_INTERVAL)) {
      cps.updateStorage();
      return;
    }
    let str = file.read(path);
    cps.pool = JSON.parse(str);
    cps.last_update = getUnixTimeStamp();
  },
  /**
github mozilla / addon-builder-helper / lib / addons-builder-helper.js View on Github external
function installAndRun(installPath, xpiPath) {
  // TODO: If the XPI is corrupted, Firefox will crash. Figure out how
  // to bail gracefully.
  if (file.exists(installPath))
    shellUtils.removeDirRecursive(installPath);
  shellUtils.makeDir(installPath);
  var zip = require("zip-file").open(xpiPath);
  zip.extractAll(installPath);
  var manifestFile = file.join(installPath, "harness-options.json");
  var manifest = JSON.parse(file.read(manifestFile));
  return {
    id: manifest.jetpackID,
    __proto__: require("bootstrap").run(manifest, installPath, print)
  };
}
github 280north / jake / lib / jake / application.js View on Github external
Application.prototype.findJakefileLocation = function() {
    var directory = FILE.cwd();
    var filename = null;

    while (!(filename = this.hasJakefile(directory)) && directory !== "/")// && !this._options.nosearch)
        directory = FILE.absolute(FILE.join(directory, ".."));

    if (!filename)
        return null;

    return [filename, directory];
}
github cappuccino / cappuccino / Objective-J / CommonJS / lib / objective-j / jake / applicationtask.js View on Github external
ApplicationTask.prototype.defineCacheManifestTask = function()
{
    if (!this.shouldGenerateCacheManifest())
        return;

    var productPath = FILE.join(this.buildProductPath(), "");
    var indexFilePath = this.buildIndexFilePath();

    // TODO: can we conditionally generate based on outdated files?
    var manifestPath = FILE.join(productPath, "app.manifest");
    Jake.task(manifestPath, function() {
        require("../cache-manifest").generateManifest(productPath, { index : indexFilePath });
    });

    this.enhance([manifestPath]);
}
github cappuccino / cappuccino / CommonJS / lib / cappuccino / nativehost.js View on Github external
CFPropertyList.modifyPlist(buildNative.join("Contents", "Info.plist"), function(plist) {

        plist.setValueForKey("CFBundleName", defaultBundleName);
        plist.setValueForKey("NHInitialResource", FILE.join(rootBaseName, options.index));

        // merge Cappuccino plist
        var cappPlistPath = rootPath.join("Info.plist");
        if (cappPlistPath.isFile())
            mergePlist(plist, cappPlistPath);

        if (options.extraPlistPath)
            mergePlist(plist, options.extraPlistPath);
    });
}
github creationix / haml-js / test / test-commonjs.js View on Github external
exports["test " + hamlFile] = function() {
        var scopeFile = hamlFile.replace(/haml$/, "js");
        var htmlFile = hamlFile.replace(/haml$/, "html");

        var haml = FILE.read(hamlFile);
        var expected = FILE.read(htmlFile);
        var scope = FILE.exists(scopeFile) ? eval("("+FILE.read(scopeFile)+")") : {};

        var js = Haml.compile(haml);
        var js_opt = Haml.optimize(js);
        var actual = Haml.execute(js_opt, scope.context, scope.locals);
        ASSERT.equal(actual.trim(), expected.trim());
    }
});
github rubyists / tiny_call_center / public / js / serenade.js View on Github external
exports.main = function commonjsMain(args) {
    if (!args[1])
        throw new Error('Usage: '+args[0]+' FILE');
    if (typeof process !== 'undefined') {
        var source = require('fs').readFileSync(require('path').join(process.cwd(), args[1]), "utf8");
    } else {
        var cwd = require("file").path(require("file").cwd());
        var source = cwd.join(args[1]).read({charset: "utf-8"});
    }
    return exports.parser.parse(source);
}
if (typeof module !== 'undefined' && require.main === module) {
github facebook / jest / packages / jest-config / src / vendor / jsonlint.js View on Github external
exports.main = function commonjsMain(args) {
  if (!args[1]) throw new Error('Usage: ' + args[0] + ' FILE');
  if (typeof process !== 'undefined') {
    var source = require('fs').readFileSync(
      require('path').join(process.cwd(), args[1]),
      'utf8',
    );
  } else {
    var cwd = require('file').path(require('file').cwd());
    var source = cwd.join(args[1]).read({charset: 'utf-8'});
  }
  return exports.parser.parse(source);
};
github zaach / jsonlint / lib / jsonlint.js View on Github external
exports.main = function commonjsMain(args) {
    if (!args[1])
        throw new Error('Usage: '+args[0]+' FILE');
    if (typeof process !== 'undefined') {
        var source = require('fs').readFileSync(require('path').join(process.cwd(), args[1]), "utf8");
    } else {
        var cwd = require("file").path(require("file").cwd());
        var source = cwd.join(args[1]).read({charset: "utf-8"});
    }
    return exports.parser.parse(source);
}
if (typeof module !== 'undefined' && require.main === module) {

file

Higher level path and file manipulation functions.

MIT
Latest version published 10 years ago

Package Health Score

50 / 100
Full package analysis