Esempio n. 1
0
	(async () => {
		t.equal(
			outputFileSync('tmp/foo', Buffer.from('a'), {mode: '0744'}),
			path.resolve('tmp'),
			'should return the path of the first created directory.'
		);

		const [dirMode, fileMode] = await Promise.all([getMode('tmp'), getMode('tmp/foo')]);

		t.equal(
			dirMode.toString(8),
			process.platform === /* istanbul ignore next */'win32' ? '40666' : '40744',
			'should reflect `mode` option to the directory mode.'
		);

		t.equal(
			fileMode.toString(8),
			process.platform === /* istanbul ignore next */'win32' ? '100666' : '100744',
			'should reflect `mode` option to the file mode.'
		);

		t.equal(await readUtf8File('tmp/foo'), 'a', 'should create a file into the new directory.');

		return rmfr('tmp');
	})();
Esempio n. 2
0
	(async () => {
		t.equal(
			outputFileSync('tmp_file', 'foo', 'utf8'),
			null,
			'should return null when it doesn\'t create any directories.'
		);

		t.equal(await readUtf8File('tmp_file'), 'foo', 'should create a file into the existing directory.');

		return rmfr('tmp_file');
	})();
Esempio n. 3
0
	(async () => {
		const [dirMode, fileMode] = await Promise.all([getMode('t/m'), getMode('t/m/p')]);

		t.equal(
			dirMode.toString(8),
			process.platform === /* istanbul ignore next */'win32' ? '40666' : '40745',
			'should reflect `dirMode` option to the directory mode.'
		);

		t.equal(
			fileMode.toString(8),
			process.platform === /* istanbul ignore next */'win32' ? '100666' : '100644',
			'should reflect `fileMode` option to the file mode.'
		);

		t.equal(
			await readUtf8File('t/m/p'),
			Buffer.from('ə', 'ascii').toString(),
			'should accept fs.writeFile\'s option.'
		);

		return rmfr('t');
	})();