當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript ModuleResolver.resolveDependentFiles方法代碼示例

本文整理匯總了TypeScript中@angular/cli/utilities/module-resolver.ModuleResolver.resolveDependentFiles方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript ModuleResolver.resolveDependentFiles方法的具體用法?TypeScript ModuleResolver.resolveDependentFiles怎麽用?TypeScript ModuleResolver.resolveDependentFiles使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在@angular/cli/utilities/module-resolver.ModuleResolver的用法示例。


在下文中一共展示了ModuleResolver.resolveDependentFiles方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

 it('when there are multiple spaces between symbols and specifier', () => {
   let oldFilePath = path.join(rootPath, 'foo-baz/qux/quux/foobar/foobar.component.ts');
   let newFilePath = path.join(rootPath, 'foo');
   let resolver = new ModuleResolver(oldFilePath, newFilePath, rootPath);
   return resolver.resolveDependentFiles()
     .then((changes) => resolver.applySortedChangePromise(changes))
     .then(() => dependentFilesUtils.createTsSourceFile(fooQuxFile))
     .then((tsFileFooQux: ts.SourceFile) => {
       let contentsFooQux = dependentFilesUtils.getImportClauses(tsFileFooQux);
       let fooQuxExpectedContent = path.normalize('../../../../foo/foobar.component');
       expect(contentsFooQux[0].specifierText).to.equal(fooQuxExpectedContent);
     })
     .then(() => dependentFilesUtils.createTsSourceFile(bazFile))
     .then((tsFileBaz: ts.SourceFile) => {
       let contentsBaz = dependentFilesUtils.getImportClauses(tsFileBaz);
       let bazExpectedContent = path.normalize('../../foo/foobar.component');
       expect(contentsBaz[1].specifierText).to.equal(bazExpectedContent);
     })
     .then(() => resolver.resolveOwnImports())
     .then((changes) => resolver.applySortedChangePromise(changes))
     .then(() => dependentFilesUtils.createTsSourceFile(fooBarFile))
     .then((tsFileFooBar: ts.SourceFile) => {
       let contentsFooBar = dependentFilesUtils.getImportClauses(tsFileFooBar);
       let fooExpectedContent = `.${path.sep}foo.component`;
       let fooQuxExpectedContent = path.normalize('../foo-baz/qux/quux/fooqux.component');
       expect(contentsFooBar[0].specifierText).to.equal(fooExpectedContent);
       expect(contentsFooBar[1].specifierText).to.equal(fooQuxExpectedContent);
     });
 });
開發者ID:Percyman,項目名稱:angular-cli,代碼行數:29,代碼來源:module-resolver.spec.ts

示例2: it

 it('when oldPath and newPath both do not have index.ts', (done) => {
   let oldFilePath = path.join(rootPath, 'bar/baz/baz.component.ts');
   let newFilePath = path.join(rootPath, 'foo-baz');
   let resolver = new ModuleResolver(oldFilePath, newFilePath, rootPath);
   return resolver.resolveDependentFiles()
     .then((changes) => resolver.applySortedChangePromise(changes))
     .then(() => dependentFilesUtils.createTsSourceFile(barFile))
     .then((tsFileBar: ts.SourceFile) => {
       let contentsBar = dependentFilesUtils.getImportClauses(tsFileBar);
       let bazExpectedContent = path.normalize('../foo-baz/baz.component');
       expect(contentsBar[0].specifierText).toBe(bazExpectedContent);
     })
     .then(() => dependentFilesUtils.createTsSourceFile(fooFile))
     .then((tsFileFoo: ts.SourceFile) => {
       let contentsFoo = dependentFilesUtils.getImportClauses(tsFileFoo);
       let bazExpectedContent = path.normalize('../foo-baz/baz.component');
       expect(contentsFoo[0].specifierText).toBe(bazExpectedContent);
     })
     .then(() => resolver.resolveOwnImports())
     .then((changes) => resolver.applySortedChangePromise(changes))
     .then(() => dependentFilesUtils.createTsSourceFile(bazFile))
     .then((tsFile: ts.SourceFile) => {
       let contentsBaz = dependentFilesUtils.getImportClauses(tsFile);
       let barExpectedContent = path.normalize('../bar/bar.component');
       let fooBarExpectedContent =
         `.${path.sep}qux${path.sep}quux${path.sep}foobar${path.sep}foobar.component`;
       expect(contentsBaz[0].specifierText).toBe(barExpectedContent);
       expect(contentsBaz[1].specifierText).toBe(fooBarExpectedContent);
     })
     .then(done, done.fail);
 });
開發者ID:germanomarques,項目名稱:angular-cli,代碼行數:31,代碼來源:module-resolver.spec.ts


注:本文中的@angular/cli/utilities/module-resolver.ModuleResolver.resolveDependentFiles方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。