How to use the file.read function in file

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 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());
    }
});

file

Higher level path and file manipulation functions.

MIT
Latest version published 10 years ago

Package Health Score

50 / 100
Full package analysis