How to use temp-write - 10 common examples

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 xojs / xo / test / cli-main.js View on Github external
test('quiet option', async t => {
	const filepath = await tempWrite('// TODO: quiet\nconsole.log()\n', 'x.js');
	const error = await t.throwsAsync(main(['--quiet', '--reporter=json', filepath]));
	const [report] = JSON.parse(error.stdout);
	t.is(report.warningCount, 0);
});
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 yuanqing / create-figma-plugin / packages / build / src / build-webpack-entry-file.js View on Github external
export async function buildWebpackEntryFile (config, key, code) {
  const modules = extractModules(config, key, [])
  if (modules.length === 0) {
    return Promise.resolve(null)
  }
  // prettier-ignore
  return tempWrite(`
    const modules = ${createRequireCode(modules)};
    const command = ${modules.length > 1 ? 'figma.command' : `'${modules[0].id}'`};
    ${code}
  `)
}
github xojs / xo / test / cli-main.js View on Github external
test('reporter option', async t => {
	const filepath = await tempWrite('console.log()\n', 'x.js');

	try {
		await main(['--reporter=compact', filepath]);
	} catch (error) {
		t.true(error.stdout.includes('Error - '));
	}
});
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...);');
});

temp-write

Write data to a random temporary file

MIT
Latest version published 2 months ago

Package Health Score

75 / 100
Full package analysis

Popular temp-write functions