How to use the pn/fs.readFile function in pn

To help you get started, we’ve selected a few pn 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 wikimedia / parsoid / bin / parse.js View on Github external
.then(function() {
		if (argv.inputfile) {
			// read input from the file, then process
			return fs.readFile(argv.inputfile, 'utf8');
		}

		// Send a message to stderr if there is no input for a while, since the
		// convention that --pageName must be used with 
github wikimedia / parsoid / tools / fetch-revision-data.js View on Github external
var fetch = Promise.async(function *(page, revid, opts) {
	var prefix = opts.prefix || null;
	var domain = opts.domain || null;
	if (!prefix && !domain) {
		domain = "en.wikipedia.org";
	}

	var parsoidOptions = {};

	if (ScriptUtils.booleanOption(opts.config)) {
		var p = (typeof (opts.config) === 'string') ?
			path.resolve('.', opts.config) :
			path.resolve(__dirname, '../config.yaml');
		// Assuming Parsoid is the first service in the list
		parsoidOptions = yaml.load(yield fs.readFile(p, 'utf8')).services[0].conf;
	}

	ScriptUtils.setTemplatingAndProcessingFlags(parsoidOptions, opts);
	ScriptUtils.setDebuggingFlags(parsoidOptions, opts);

	if (parsoidOptions.localsettings) {
		parsoidOptions.localsettings = path.resolve(__dirname, parsoidOptions.localsettings);
	}

	var pc = new ParsoidConfig(null, parsoidOptions);
	if (!prefix) {
		// domain has been provided
		prefix = pc.getPrefixFor(domain);
	} else if (!domain) {
		// prefix has been set
		domain = pc.mwApiMap.get(prefix).domain;
github wikimedia / parsoid / bin / parse.js View on Github external
} else if (!(prefix || domain)) {
		domain = 'en.wikipedia.org';
	}

	var parsoidOptions = {
		linting: argv.linting,
		loadWMF: argv.loadWMF,
		useWorker: argv.useWorker,
	};

	if (ScriptUtils.booleanOption(argv.config)) {
		var p = (typeof (argv.config) === 'string') ?
			path.resolve('.', argv.config) :
			path.resolve(__dirname, '../config.yaml');
		// Assuming Parsoid is the first service in the list
		parsoidOptions = yaml.load(yield fs.readFile(p, 'utf8')).services[0].conf;
	}

	ScriptUtils.setTemplatingAndProcessingFlags(parsoidOptions, argv);
	ScriptUtils.setDebuggingFlags(parsoidOptions, argv);

	// Offline shortcut
	if (argv.offline) {
		parsoidOptions.fetchConfig = false;
		parsoidOptions.fetchTemplates = false;
		parsoidOptions.fetchImageInfo = false;
		parsoidOptions.usePHPPreProcessor = false;
		parsoidOptions.expandExtensions = false;
	}

	if (parsoidOptions.localsettings) {
		parsoidOptions.localsettings = path.resolve(__dirname, parsoidOptions.localsettings);
github jkphl / svg-sprite / test / svg-sprite.js View on Github external
function compareSvg2Png(svg, png, expected, diff, done, msg) {
    mkdirp.sync(path.dirname(png));
    var ecb = function (err) {
        console.log(err);
        should(err).not.ok;
        done();
    };
    fs.readFile(svg)
        .then(svg2png)
        .then(function (buffer) {
            fs.writeFile(png, buffer)
                .then(function () {
                    imageDiff({
                        actualImage: png,
                        expectedImage: expected,
                        diffImage: diff
                    }, function (err, imagesAreSame) {
                        should(err).not.ok;
                        should.ok(imagesAreSame, msg);
                        done();
                    });
                })
                .catch(ecb);
        })
github jsdom / jsdom / test / api / encoding.js View on Github external
function readFixture(fixture) {
  return fs.readFile(fixturePath(fixture));
}
github mjswensen / themer / lib / index.spec.js View on Github external
it('should render output files properly', async () => {
      await child_process.execFile(pathToExecutable, args).promise;
      const contents = await fs.readFile(testOutputFile, 'utf8');
      expect(contents).toEqual(outputFileContents);
    });
github flaviuse / mern-authentication / client / node_modules / jsdom / lib / api.js View on Github external
return Promise.resolve().then(() => {
      options = normalizeFromFileOptions(filename, options);

      return fs.readFile(filename).then(buffer => {
        return new JSDOM(buffer, options);
      });
    });
  }
github jsdom / jsdom / lib / api.js View on Github external
return Promise.resolve().then(() => {
      options = normalizeFromFileOptions(filename, options);

      return fs.readFile(filename).then(buffer => {
        return new JSDOM(buffer, options);
      });
    });
  }
github wikimedia / parsoid / tools / fetch-parserTests.txt.js View on Github external
var computeSHA1 = Promise.async(function *(targetName) {
	var targetPath = path.join(testDir, targetName);
	if (!(yield fs.exists(targetPath))) {
		return "";
	}
	var contents = yield fs.readFile(targetPath);
	return crypto.createHash('sha1').update(contents).digest('hex')
		.toLowerCase();
});
github sx1989827 / DOClever / node_modules / jsdom / lib / api.js View on Github external
return Promise.resolve().then(() => {
      options = normalizeFromFileOptions(filename, options);

      return fs.readFile(filename).then(buffer => {
        return new JSDOM(buffer, options);
      });
    });
  }