How to use the pn/fs.writeFile 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 / tools / fetch-parserTests.txt.js View on Github external
result.on('data', function(data) { res += data; });
			result.on('end', function() { resolve(res); });
		}).on('error', function(err) {
			console.error(err);
			reject(err);
		});
	}))[0].sha;

	// download latest file
	yield fetch(targetName, gitCommit, true);
	var fileHash = yield computeSHA1(targetName);

	// now rewrite this file!
	file.expectedSHA1 = fileHash;
	file.latestCommit = gitCommit;
	yield fs.writeFile(testFilesPath, JSON.stringify(testFiles, null, '\t'), 'utf8');
	console.log('Updated', testFilesPath);
});
github wikimedia / parsoid / bin / parserTests.js View on Github external
const oldExists = yield fs.exists(this.blackListPath);
			if (oldExists) {
				old = yield fs.readFile(this.blackListPath, 'utf8');
			}
			const testBlackList = options.modes.reduce((tbl, mode) => {
				this.stats.modes[mode].failList.forEach((fail) => {
					if (!tbl.hasOwnProperty(fail.title)) {
						tbl[fail.title] = {};
					}
					tbl[fail.title][mode] = fail.raw;
				});
				return tbl;
			}, {});
			const contents = JSON.stringify(testBlackList, null, "    ");
			if (ScriptUtils.booleanOption(options['rewrite-blacklist'])) {
				yield fs.writeFile(this.blackListPath, contents, 'utf8');
			} else if (allModes && oldExists) {
				blacklistChanged = (contents !== old);
			}
		}

		// Write updated tests from failed ones
		if (options['update-tests'] ||
				ScriptUtils.booleanOption(options['update-unexpected'])) {
			var updateFormat = (options['update-tests'] === 'raw') ?
				'raw' : 'actualNormalized';
			var parserTests = yield fs.readFile(this.testFilePath, 'utf8');
			this.stats.modes.wt2html.failList.forEach(function(fail) {
				if (options['update-tests'] || fail.unexpected) {
					var exp = new RegExp("(" + /!!\s*test\s*/.source +
						JSUtils.escapeRegExp(fail.title) + /(?:(?!!!\s*end)[\s\S])*/.source +
						")(" + JSUtils.escapeRegExp(fail.expected) + ")", "m");
github jsdom / webidl2js / lib / transformer.js View on Github external
async _writeFiles(outputDir) {
    const utilsText = await fs.readFile(path.resolve(__dirname, "output/utils.js"));
    await fs.writeFile(this.utilPath, utilsText);

    const { interfaces, dictionaries, enumerations } = this.ctx;

    for (const obj of interfaces.values()) {
      let source = obj.toString();

      let implFile = path.relative(outputDir, path.resolve(obj.opts.implDir, obj.name + this.ctx.implSuffix));
      implFile = implFile.replace(/\\/g, "/"); // fix windows file paths
      if (implFile[0] !== ".") {
        implFile = "./" + implFile;
      }

      let relativeUtils = path.relative(outputDir, this.utilPath).replace(/\\/g, "/");
      if (relativeUtils[0] !== ".") {
        relativeUtils = "./" + relativeUtils;
      }
github domenic / svg2png / test / success-tests / rebaseline.js View on Github external
        .then(buffer => fs.writeFile(relative(`${index}.png`), buffer))
        .catch(e => console.error(`${test.file}\n\n${e.stack}\n\n\n`));
github jkphl / svg-sprite / test / svg-sprite.js View on Github external
.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);
        })
        .catch(ecb);
github mjswensen / themer / cli / packages / themer-atom-ui / lib / index.spec.js View on Github external
              .then(() => fs.writeFile(outputFilePath, file.contents))
              .then(() => outputFilePath);
github mjswensen / themer-gui / main / export.js View on Github external
(userOutputPath) => {
        if (userOutputPath) {
          fs.writeFile(userOutputPath, colorsFileContents);
        }
      }
    );
github jsdom / webidl2js / lib / transformer.js View on Github external
if (relativeUtils[0] !== ".") {
        relativeUtils = "./" + relativeUtils;
      }

      source = `
        "use strict";

        const conversions = require("webidl-conversions");
        const utils = require("${relativeUtils}");
        ${source}
        const Impl = require("${implFile}.js");
      `;

      source = this._prettify(source);

      await fs.writeFile(path.join(outputDir, obj.name + ".js"), source);
    }

    for (const obj of dictionaries.values()) {
      let source = obj.toString();

      let relativeUtils = path.relative(outputDir, this.utilPath).replace(/\\/g, "/");
      if (relativeUtils[0] !== ".") {
        relativeUtils = "./" + relativeUtils;
      }

      source = `
        "use strict";

        const conversions = require("webidl-conversions");
        const utils = require("${relativeUtils}");
        ${source}
github wikimedia / parsoid / bin / parse.js View on Github external
scrubWikitext: argv.scrubWikitext,
			});
		} else {
			str = html;
		}
	} else {
		str = out.wt;
	}
	var stdout = process.stdout;
	stdout.write(str);
	if (stdout.isTTY) {
		stdout.write('\n');
	}
	if (argv.record) {
		var nockCalls = nock.recorder.play();
		yield fs.writeFile(
			nocksFile,
			"var nock = require('nock');\n" + nockCalls.join('\n'),
			'utf8'
		);
	}
})().done();
github mjswensen / themer / packages / themer / lib / themer.js View on Github external
              () => fs.writeFile(outputFilePath, output.file.contents)
            );