• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript pfs.mkdirp函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中vs/base/node/pfs.mkdirp函数的典型用法代码示例。如果您正苦于以下问题:TypeScript mkdirp函数的具体用法?TypeScript mkdirp怎么用?TypeScript mkdirp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了mkdirp函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: test

	test('simple file operations, ignore', async () => {
		let request: IWatcherRequest = { basePath: testDir, ignored: ['**/b/**', '**/*.js', '.git/**'] };
		service.setRoots([request]);
		await wait(300);

		assert.equal(service.wacherCount, 1);

		// create various ignored files
		let file1 = path.join(bFolder, 'file1.txt'); // hidden
		await pfs.writeFile(file1, 'Hello');
		let file2 = path.join(b2Folder, 'file2.txt'); // hidden
		await pfs.writeFile(file2, 'Hello');
		let folder1 = path.join(bFolder, 'folder1'); // hidden
		await pfs.mkdirp(folder1);
		let folder2 = path.join(aFolder, 'b'); // hidden
		await pfs.mkdirp(folder2);
		let folder3 = path.join(testDir, '.git'); // hidden
		await pfs.mkdirp(folder3);
		let folder4 = path.join(testDir, '.git1');
		await pfs.mkdirp(folder4);
		let folder5 = path.join(aFolder, '.git');
		await pfs.mkdirp(folder5);
		let file3 = path.join(aFolder, 'file3.js'); // hidden
		await pfs.writeFile(file3, 'var x;');
		let file4 = path.join(aFolder, 'file4.txt');
		await pfs.writeFile(file4, 'Hello');
		await assertFileEvents(result, [{ path: file4, type: FileChangeType.ADDED }, { path: folder4, type: FileChangeType.ADDED }, { path: folder5, type: FileChangeType.ADDED }]);

		// move some files
		let movedFile1 = path.join(folder2, 'file1.txt'); // from ignored to ignored
		await pfs.rename(file1, movedFile1);
		let movedFile2 = path.join(aFolder, 'file2.txt'); // from ignored to visible
		await pfs.rename(file2, movedFile2);
		let movedFile3 = path.join(aFolder, 'file3.txt'); // from ignored file ext to visible
		await pfs.rename(file3, movedFile3);
		await assertFileEvents(result, [{ path: movedFile2, type: FileChangeType.ADDED }, { path: movedFile3, type: FileChangeType.ADDED }]);

		// delete all files
		await pfs.del(movedFile1); // hidden
		await pfs.del(movedFile2);
		await pfs.del(movedFile3);
		await pfs.del(folder1); // hidden
		await pfs.del(folder2); // hidden
		await pfs.del(folder3); // hidden
		await pfs.del(folder4);
		await pfs.del(folder5);
		await pfs.del(file4);
		await assertFileEvents(result, [{ path: movedFile2, type: FileChangeType.DELETED }, { path: movedFile3, type: FileChangeType.DELETED }, { path: file4, type: FileChangeType.DELETED }, { path: folder4, type: FileChangeType.DELETED }, { path: folder5, type: FileChangeType.DELETED }]);
	});
开发者ID:DonJayamanne,项目名称:vscode,代码行数:49,代码来源:chockidarWatcherService.test.ts


示例2: test

	test('writeFile - parallel write on same files works and is sequentalized', function (done: () => void) {
		const id = uuid.generateUuid();
		const parentDir = path.join(os.tmpdir(), 'vsctests', id);
		const newDir = path.join(parentDir, 'pfs', id);
		const testFile = path.join(newDir, 'writefile.txt');

		const onMkdirp = error => {
			if (error) {
				return onError(error, done);
			}

			assert.ok(fs.existsSync(newDir));

			TPromise.join([
				pfs.writeFile(testFile, 'Hello World 1', null),
				pfs.writeFile(testFile, 'Hello World 2', null),
				TPromise.timeout(10).then(() => pfs.writeFile(testFile, 'Hello World 3', null)),
				pfs.writeFile(testFile, 'Hello World 4', null),
				TPromise.timeout(10).then(() => pfs.writeFile(testFile, 'Hello World 5', null))
			]).done(() => {
				assert.equal(fs.readFileSync(testFile), 'Hello World 5');

				extfs.del(parentDir, os.tmpdir(), () => { }, done);
			}, error => onError(error, done));
		};

		pfs.mkdirp(newDir, 493).done(() => onMkdirp(null), error => onMkdirp(error));
	});
开发者ID:JarnoNijboer,项目名称:vscode,代码行数:28,代码来源:pfs.test.ts


示例3: test

	test('writeFile - parallel write on different files works', function () {
		const id = uuid.generateUuid();
		const parentDir = path.join(os.tmpdir(), 'vsctests', id);
		const newDir = path.join(parentDir, 'pfs', id);
		const testFile1 = path.join(newDir, 'writefile1.txt');
		const testFile2 = path.join(newDir, 'writefile2.txt');
		const testFile3 = path.join(newDir, 'writefile3.txt');
		const testFile4 = path.join(newDir, 'writefile4.txt');
		const testFile5 = path.join(newDir, 'writefile5.txt');

		return pfs.mkdirp(newDir, 493).then(() => {
			assert.ok(fs.existsSync(newDir));

			return Promise.all([
				pfs.writeFile(testFile1, 'Hello World 1', null),
				pfs.writeFile(testFile2, 'Hello World 2', null),
				pfs.writeFile(testFile3, 'Hello World 3', null),
				pfs.writeFile(testFile4, 'Hello World 4', null),
				pfs.writeFile(testFile5, 'Hello World 5', null)
			]).then(() => {
				assert.equal(fs.readFileSync(testFile1), 'Hello World 1');
				assert.equal(fs.readFileSync(testFile2), 'Hello World 2');
				assert.equal(fs.readFileSync(testFile3), 'Hello World 3');
				assert.equal(fs.readFileSync(testFile4), 'Hello World 4');
				assert.equal(fs.readFileSync(testFile5), 'Hello World 5');

				return pfs.del(parentDir, os.tmpdir());
			});
		});
	});
开发者ID:donaldpipowitch,项目名称:vscode,代码行数:30,代码来源:pfs.test.ts


示例4: test

	test('default', async function () {
		await mkdirp(parentDir);
		fs.writeFileSync(installSource, 'my.install.source');
		const props = await resolveWorkbenchCommonProperties(nestStorage2Service, commit, version, 'someMachineId', installSource);
		assert.ok('commitHash' in props);
		assert.ok('sessionID' in props);
		assert.ok('timestamp' in props);
		assert.ok('common.platform' in props);
		assert.ok('common.nodePlatform' in props);
		assert.ok('common.nodeArch' in props);
		assert.ok('common.timesincesessionstart' in props);
		assert.ok('common.sequence' in props);
		// assert.ok('common.version.shell' in first.data); // only when running on electron
		// assert.ok('common.version.renderer' in first.data);
		assert.ok('common.platformVersion' in props, 'platformVersion');
		assert.ok('version' in props);
		assert.equal(props['common.source'], 'my.install.source');
		assert.ok('common.firstSessionDate' in props, 'firstSessionDate');
		assert.ok('common.lastSessionDate' in props, 'lastSessionDate'); // conditional, see below, 'lastSessionDate'ow
		assert.ok('common.isNewSession' in props, 'isNewSession');
		// machine id et al
		assert.ok('common.instanceId' in props, 'instanceId');
		assert.ok('common.machineId' in props, 'machineId');
		fs.unlinkSync(installSource);
		const props_1 = await resolveWorkbenchCommonProperties(nestStorage2Service, commit, version, 'someMachineId', installSource);
		assert.ok(!('common.source' in props_1));
	});
开发者ID:KTXSoftware,项目名称:KodeStudio,代码行数:27,代码来源:commonProperties.test.ts


示例5: save

export function save(file: string, content: string): any {
	mkdirp(dirname(file)).then(() => {
		return writeFile(file, content, 'ascii');
	}, err => {
		//
	});
}
开发者ID:AjuanM,项目名称:vscode,代码行数:7,代码来源:fileAccessor.ts


示例6: test

	test('basics (corrupt DB falls back to empty DB if backup is corrupt)', async () => {
		const storageDir = uniqueStorageDir();

		await mkdirp(storageDir);

		const storagePath = join(storageDir, 'storage.db');
		let storage = new SQLiteStorageImpl({ path: storagePath });

		const items = new Map<string, string>();
		items.set('foo', 'bar');
		items.set('some/foo/path', 'some/bar/path');
		items.set(JSON.stringify({ foo: 'bar' }), JSON.stringify({ bar: 'foo' }));

		await storage.updateItems({ insert: items });
		await storage.close();

		await writeFile(storagePath, 'This is now a broken DB');
		await writeFile(`${storagePath}.backup`, 'This is now also a broken DB');

		storage = new SQLiteStorageImpl({ path: storagePath });

		const storedItems = await storage.getItems();
		equal(storedItems.size, 0);

		await testDBBasics(storagePath);

		await del(storageDir, tmpdir());
	});
开发者ID:,项目名称:,代码行数:28,代码来源:


示例7: extractEntry

function extractEntry(stream: Readable, fileName: string, mode: number, targetPath: string, options: IOptions, token: CancellationToken): TPromise<void> {
	const dirName = path.dirname(fileName);
	const targetDirName = path.join(targetPath, dirName);
	if (targetDirName.indexOf(targetPath) !== 0) {
		return TPromise.wrapError(new Error(nls.localize('invalid file', "Error extracting {0}. Invalid file.", fileName)));
	}
	const targetFileName = path.join(targetPath, fileName);

	let istream: WriteStream;

	once(token.onCancellationRequested)(() => {
		if (istream) {
			istream.close();
		}
	});

	return mkdirp(targetDirName, void 0, token).then(() => new TPromise((c, e) => {
		if (token.isCancellationRequested) {
			return;
		}

		istream = createWriteStream(targetFileName, { mode });
		istream.once('close', () => c(null));
		istream.once('error', e);
		stream.once('error', e);
		stream.pipe(istream);
	}));
}
开发者ID:developers23,项目名称:vscode,代码行数:28,代码来源:zip.ts


示例8: extractEntry

function extractEntry(stream: Readable, fileName: string, mode: number, targetPath: string, options: IOptions, token: CancellationToken): Promise<void> {
	const dirName = path.dirname(fileName);
	const targetDirName = path.join(targetPath, dirName);
	if (targetDirName.indexOf(targetPath) !== 0) {
		return Promise.reject(new Error(nls.localize('invalid file', "Error extracting {0}. Invalid file.", fileName)));
	}
	const targetFileName = path.join(targetPath, fileName);

	let istream: WriteStream;

	Event.once(token.onCancellationRequested)(() => {
		if (istream) {
			istream.destroy();
		}
	});

	return Promise.resolve(mkdirp(targetDirName, undefined, token)).then(() => new Promise<void>((c, e) => {
		if (token.isCancellationRequested) {
			return;
		}

		try {
			istream = createWriteStream(targetFileName, { mode });
			istream.once('close', () => c());
			istream.once('error', e);
			stream.once('error', e);
			stream.pipe(istream);
		} catch (error) {
			e(error);
		}
	}));
}
开发者ID:joelday,项目名称:vscode,代码行数:32,代码来源:zip.ts


示例9: test

	test('Migrate Data', async () => {
		class StorageTestEnvironmentService extends EnvironmentService {

			constructor(private workspaceStorageFolderPath: string, private _extensionsPath) {
				super(parseArgs(process.argv), process.execPath);
			}

			get workspaceStorageHome(): string {
				return this.workspaceStorageFolderPath;
			}

			get extensionsPath(): string {
				return this._extensionsPath;
			}
		}

		const storageDir = uniqueStorageDir();
		await mkdirp(storageDir);

		const storage = new StorageService(new InMemoryStorageDatabase(), new NullLogService(), new StorageTestEnvironmentService(storageDir, storageDir));
		await storage.initialize({ id: String(Date.now()) });

		storage.store('bar', 'foo', StorageScope.WORKSPACE);
		storage.store('barNumber', 55, StorageScope.WORKSPACE);
		storage.store('barBoolean', true, StorageScope.GLOBAL);

		await storage.migrate({ id: String(Date.now() + 100) });

		equal(storage.get('bar', StorageScope.WORKSPACE), 'foo');
		equal(storage.getInteger('barNumber', StorageScope.WORKSPACE), 55);
		equal(storage.getBoolean('barBoolean', StorageScope.GLOBAL), true);

		await storage.close();
		await del(storageDir, tmpdir());
	});
开发者ID:donaldpipowitch,项目名称:vscode,代码行数:35,代码来源:storageService.test.ts



注:本文中的vs/base/node/pfs.mkdirp函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript pfs.readFile函数代码示例发布时间:2022-05-25
下一篇:
TypeScript pfs.fileExists函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap