How to use the temp-write.sync function in temp-write

To help you get started, we’ve selected a few temp-write 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 rocketlaunchr / electron-alert / dist / alert.js View on Github external
draggable === true ? 'style="-webkit-app-region:drag"' : ""
		}>
      
    
    `;

		// Disable menu (and refresh shortcuts)
		this.browserWindow.setMenu(null);

		// Save html
		let filepath = tempWrite.sync(html, "swal.html");

		this.browserWindow.loadURL("file://" + filepath);

		if (isMac) {
			// Disable Window Refresh (Cmd+R)
			this.browserWindow.on("focus", event => {
				globalShortcut.registerAll(
					["CommandOrControl+R", "CommandOrControl+Shift+R"],
					() => {}
				);
			});

			this.browserWindow.on("blur", event => {
				globalShortcut.unregister("CommandOrControl+R");
				globalShortcut.unregister("CommandOrControl+Shift+R");
			});
github sindresorhus / move-file / test / async.js View on Github external
test('overwrite option', async t => {
	await t.throwsAsync(
		moveFile(tempWrite.sync('x'), tempWrite.sync('y'), {overwrite: false}),
		/The destination file exists/
	);
});
github typicode / json-server / __tests__ / cli / index.js View on Github external
beforeEach(() => {
    dbFile = tempWrite.sync(
      JSON.stringify({
        posts: [{ id: 1 }, { _id: 2 }],
        comments: [{ id: 1, post_id: 1 }]
      }),
      'db.json'
    )

    routesFile = tempWrite.sync(
      JSON.stringify({ '/blog/*': '/$1' }),
      'routes.json'
    )

    ++PORT
    request = supertest(`http://localhost:${PORT}`)
  })
github bokub / lyo / test / usage.js View on Github external
test.serial('getUsage works well', t => {
	const file = tempWrite.sync('module.exports = input => input + \'!\'', 'test.js');
	usage.getUsage({input: file});
	t.true(logged.indexOf('') !== -1);
});
github bokub / lyo / test / usage.js View on Github external
test.serial('getModuleSignature works for functions', t => {
	const fileA = tempWrite.sync('module.exports = (a, b) => a + b;', 'a.js');
	const fileB = tempWrite.sync('module.exports = () => document.body.innerText = \'Hi\';', 'b.js');
	const fileC = tempWrite.sync('module.exports = (a, b, c, d, e) => a;', 'c.js');
	t.is(usage.getModuleSignature({input: fileA, name: 'concat'}), 'concat(foo, bar);');
	t.is(usage.getModuleSignature({input: fileB, name: 'sayHi'}), 'sayHi();');
	t.is(usage.getModuleSignature({input: fileC, name: 'lotsOfArgs'}), 'lotsOfArgs(args...);');
});
github sindresorhus / move-file / test / sync.js View on Github external
t.throws(() => {
		moveFile.sync(tempWrite.sync('x'), tempWrite.sync('y'), {overwrite: false});
	}, /The destination file exists/);
});
github bokub / lyo / test / usage.js View on Github external
test.serial('getModuleSignature works for functions', t => {
	const fileA = tempWrite.sync('module.exports = (a, b) => a + b;', 'a.js');
	const fileB = tempWrite.sync('module.exports = () => document.body.innerText = \'Hi\';', 'b.js');
	const fileC = tempWrite.sync('module.exports = (a, b, c, d, e) => a;', 'c.js');
	t.is(usage.getModuleSignature({input: fileA, name: 'concat'}), 'concat(foo, bar);');
	t.is(usage.getModuleSignature({input: fileB, name: 'sayHi'}), 'sayHi();');
	t.is(usage.getModuleSignature({input: fileC, name: 'lotsOfArgs'}), 'lotsOfArgs(args...);');
});
github mosjs / mos / packages / mos-init / index.spec.js View on Github external
function run (pkg) {
  var filepath = tempWrite.sync(JSON.stringify(pkg), 'package.json')

  return mosInit({
    cwd: path.dirname(filepath),
    skipInstall: true,
  }).then(function () { return JSON.parse(fs.readFileSync(filepath, 'utf8')) })
}
github sindresorhus / open-cli / cli.js View on Github external
(async () => {
	if (input) {
		await open(input, cli.flags);
	} else {
		const stdin = await getStdin.buffer();
		const type = fileType(stdin);
		const extension = cli.flags.extension || (type && type.ext) || 'txt';
		await open(tempWrite.sync(stdin, `open.${extension}`), cli.flags);
	}
})();

temp-write

Write data to a random temporary file

MIT
Latest version published 4 months ago

Package Health Score

70 / 100
Full package analysis

Popular temp-write functions