本文整理汇总了TypeScript中@angular-devkit/schematics.HostSink.commit方法的典型用法代码示例。如果您正苦于以下问题:TypeScript HostSink.commit方法的具体用法?TypeScript HostSink.commit怎么用?TypeScript HostSink.commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@angular-devkit/schematics.HostSink
的用法示例。
在下文中一共展示了HostSink.commit方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('works', done => {
const host = new virtualFs.test.TestHost({
'/hello': 'world',
'/sub/directory/file2': '',
'/sub/file1': '',
});
const tree = new HostCreateTree(host);
tree.create('/test', 'testing 1 2');
const recorder = tree.beginUpdate('/test');
recorder.insertLeft(8, 'testing ');
tree.commitUpdate(recorder);
const files = ['/hello', '/sub/directory/file2', '/sub/file1', '/test'];
const treeFiles: string[] = [];
tree.visit(path => treeFiles.push(path));
treeFiles.sort();
expect(treeFiles).toEqual(files);
const outputHost = new virtualFs.test.TestHost();
const sink = new HostSink(outputHost);
sink.commit(optimize(tree))
.toPromise()
.then(() => {
const tmpFiles = outputHost.files.sort();
expect(tmpFiles as string[]).toEqual(files);
expect(outputHost.sync.read(normalize('/test')).toString())
.toBe('testing testing 1 2');
})
.then(done, done.fail);
});
示例2: beforeEach
beforeEach(done => {
// Commit a version of the tree.
const host = new virtualFs.test.TestHost({
'/file0': '/file0',
'/sub/directory/file2': '/sub/directory/file2',
'/sub/file1': '/sub/file1',
});
const tree = new HostCreateTree(host);
const outputHost = new virtualFs.test.TestHost();
const sink = new HostSink(outputHost);
sink.commit(optimize(tree))
.toPromise()
.then(done, done.fail);
});
示例3: it
it('can rename files', done => {
const host = new virtualFs.test.TestHost({
'/file0': '/file0',
});
const tree = new FileSystemTree(host);
tree.rename('/file0', '/file1');
const sink = new HostSink(host);
sink.commit(optimize(tree))
.toPromise()
.then(() => {
expect(host.sync.exists(normalize('/file0'))).toBe(false);
expect(host.sync.exists(normalize('/file1'))).toBe(true);
})
.then(done, done.fail);
});