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


TypeScript path.posix類代碼示例

本文整理匯總了TypeScript中path.posix的典型用法代碼示例。如果您正苦於以下問題:TypeScript posix類的具體用法?TypeScript posix怎麽用?TypeScript posix使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: function

export default function() {
  // These testcases are specific to one uncommon behaviour in path module. Few
  // of the functions in path module, treat '' strings as current working
  // directory. This test makes sure that the behaviour is intact between commits.
  // See: https://github.com/nodejs/node/pull/2106

  var pwd = process.cwd();

  // join will internally ignore all the zero-length strings and it will return
  // '.' if the joined string is a zero-length string.
  assert.equal(path.posix.join(''), '.');
  assert.equal(path.posix.join('', ''), '.');
  assert.equal(path.join(pwd), pwd);
  assert.equal(path.join(pwd, ''), pwd);

  // normalize will return '.' if the input is a zero-length string
  assert.equal(path.posix.normalize(''), '.');
  assert.equal(path.normalize(pwd), pwd);

  // Since '' is not a valid path in any of the common environments, return false
  assert.equal(path.posix.isAbsolute(''), false);

  // resolve, internally ignores all the zero-length strings and returns the
  // current working directory
  assert.equal(path.resolve(''), pwd);
  assert.equal(path.resolve('', ''), pwd);

  // relative, internally calls resolve. So, '' is actually the current directory
  assert.equal(path.relative('', pwd), '');
  assert.equal(path.relative(pwd, ''), '');
  assert.equal(path.relative(pwd, pwd), '');
};
開發者ID:diegolameira,項目名稱:codesandbox-client,代碼行數:32,代碼來源:node-path-zero-length-strings.ts

示例2: constructor

 private constructor(
     relativeFlatIndexPath: string, readonly entryPoint: string,
     readonly moduleName: string|null) {
   this.flatIndexPath = path.posix.join(path.posix.dirname(entryPoint), relativeFlatIndexPath)
                            .replace(/\.js$/, '') +
       '.ts';
 }
開發者ID:cyrilletuzi,項目名稱:angular,代碼行數:7,代碼來源:flat_index_generator.ts

示例3:

        .map(match => {
          const relativePath = path.posix.relative(slashedDirname, match);

          return path.posix.dirname(match) === slashedDirname
            ? `./${relativePath}`
            : relativePath;
        })
開發者ID:Volune,項目名稱:jest,代碼行數:7,代碼來源:helpers.ts

示例4:

		return service.resolveFile(uri.file(path.join(testDir, 'index.html'))).then(source => {
			const targetParent = uri.file(path.dirname(source.resource.fsPath));
			const target = targetParent.with({ path: path.posix.join(targetParent.path, path.posix.basename(source.resource.path)) });
			return service.copyFile(source.resource, target, true).then(copied => {
				assert.equal(copied.size, source.size);
			});
		});
開發者ID:liunian,項目名稱:vscode,代碼行數:7,代碼來源:fileService.test.ts

示例5: webcomponentsLiteToBundle

  /**
   * Checks if a path points to webcomponents-lite.js and will change it to
   * webcomponents-bundle.js if it does.
   *
   * @param filePath path to transform.
   */
  private webcomponentsLiteToBundle(filePath: string) {
    const pathObject = path.posix.parse(filePath);

    if (pathObject.base === 'webcomponents-lite.js') {
      pathObject.base = 'webcomponents-bundle.js';
    }

    return path.posix.format(pathObject);
  }
開發者ID:,項目名稱:,代碼行數:15,代碼來源:

示例6: pathFromUrl

export function pathFromUrl(
    root: LocalFsPath,
    // TODO(usergenic): PackageRelativeUrl are not *necessarily* always just a
    // relative path from root.  Maybe subclass as PackageRelativeUrlPath or
    // something if this function doesn't disappear after
    // https://github.com/Polymer/polymer-build/issues/324 is addressed.
    url: PackageRelativeUrl): LocalFsPath {
  return path.normalize(decodeURIComponent(path.posix.join(
             posixifyPath(root), path.posix.join('/', url)))) as LocalFsPath;
}
開發者ID:MehdiRaash,項目名稱:tools,代碼行數:10,代碼來源:path-transformers.ts

示例7: toDepNameAndPath

 toDepNameAndPath(relativePath: string): { depName: string; path: string; } {
     let depName = path.join(path.dirname(this._current.depName), relativePath);
     let depPath = path.join(path.dirname(this._current.path), relativePath);
     if (path.posix) {
         // (windows) for git cli
         // path.posix are exists after node v0.12
         depName = path.posix.join(path.dirname(this._current.depName), relativePath);
         depPath = path.posix.join(path.dirname(this._current.path), relativePath);
     }
     return {
         depName: depName,
         path: depPath,
     };
 }
開發者ID:vvakame,項目名稱:packagemanager-backend,代碼行數:14,代碼來源:result.ts

示例8: it

 it('should list lazy routes recursively', () => {
   writeSomeRoutes();
   const {program, host, options} =
       createProgram(['src/main.ts', 'src/child.ts', 'src/child2.ts']);
   const routes = NgTools_InternalApi_NG_2.listLazyRoutes({
     program,
     host,
     angularCompilerOptions: options,
     entryModule: 'src/main#MainModule',
   });
   expect(routes).toEqual({
     './child#ChildModule': path.posix.join(testSupport.basePath, 'src/child.ts'),
     './child2#ChildModule2': path.posix.join(testSupport.basePath, 'src/child2.ts'),
   });
 });
開發者ID:Cammisuli,項目名稱:angular,代碼行數:15,代碼來源:ngtools_api_spec.ts

示例9: Buffer

    return this._getBundles().then((bundles) => {
      let sharedDepsBundle = (this.shell)
          ? this.urlFromPath(this.shell)
          : this.sharedBundleUrl;
      let sharedDeps = bundles.get(sharedDepsBundle) || [];
      let promises = [];

      if (this.shell) {
        let shellFile = this.analyzer.getFile(this.shell);
        console.assert(shellFile != null);
        let newShellContent = this._addSharedImportsToShell(bundles);
        shellFile.contents = new Buffer(newShellContent);
      }

      for (let fragment of this.allFragments) {
        let fragmentUrl = this.urlFromPath(fragment);
        let addedImports = (fragment === this.shell && this.shell)
            ? []
            : [path.relative(path.dirname(fragmentUrl), sharedDepsBundle)];
        let excludes = (fragment === this.shell && this.shell)
            ? []
            : sharedDeps.concat(sharedDepsBundle);

        promises.push(new Promise((resolve, reject) => {
          let vulcanize = new Vulcanize({
            abspath: null,
            fsResolver: this.analyzer.resolver,
            addedImports: addedImports,
            stripExcludes: excludes,
            inlineScripts: true,
            inlineCss: true,
            inputUrl: fragmentUrl,
          });
          vulcanize.process(null, (err, doc) => {
            if (err) {
              reject(err);
            } else {
              resolve({
                url: fragment,
                contents: doc,
              });
            }
          });
        }));
      }
      // vulcanize the shared bundle
      if (!this.shell && sharedDeps && sharedDeps.length !== 0) {
        logger.info(`generating shared bundle`);
        promises.push(this._generateSharedBundle(sharedDeps));
      }
      return Promise.all(promises).then((bundles) => {
        // convert {url,contents}[] into a Map
        let contentsMap = new Map();
        for (let bundle of bundles) {
          contentsMap.set(bundle.url, bundle.contents);
        }
        return contentsMap;
      });
    });
開發者ID:honzalo,項目名稱:polymer-cli,代碼行數:59,代碼來源:bundle.ts


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