当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript posix.basename方法代码示例

本文整理汇总了TypeScript中path.posix.basename方法的典型用法代码示例。如果您正苦于以下问题:TypeScript posix.basename方法的具体用法?TypeScript posix.basename怎么用?TypeScript posix.basename使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在path.posix的用法示例。


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

示例1: factoryFor

  factoryFor(original: ts.SourceFile, genFilePath: string): ts.SourceFile {
    const relativePathToSource =
        './' + path.posix.basename(original.fileName).replace(TS_DTS_SUFFIX, '');
    // Collect a list of classes that need to have factory types emitted for them.
    const symbolNames = original
                            .statements
                            // Pick out top level class declarations...
                            .filter(ts.isClassDeclaration)
                            // which are named, exported, and have decorators.
                            .filter(
                                decl => isExported(decl) && decl.decorators !== undefined &&
                                    decl.name !== undefined)
                            // Grab the symbol name.
                            .map(decl => decl.name !.text);

    // For each symbol name, generate a constant export of the corresponding NgFactory.
    // This will encompass a lot of symbols which don't need factories, but that's okay
    // because it won't miss any that do.
    const varLines = symbolNames.map(
        name => `export const ${name}NgFactory = new i0.ɵNgModuleFactory(${name});`);
    const sourceText = [
      // This might be incorrect if the current package being compiled is Angular core, but it's
      // okay to leave in at type checking time. TypeScript can handle this reference via its path
      // mapping, but downstream bundlers can't. If the current package is core itself, this will be
      // replaced in the factory transformer before emit.
      `import * as i0 from '@angular/core';`,
      `import {${symbolNames.join(', ')}} from '${relativePathToSource}';`,
      ...varLines,
    ].join('\n');
    return ts.createSourceFile(
        genFilePath, sourceText, original.languageVersion, true, ts.ScriptKind.TS);
  }
开发者ID:DeepanParikh,项目名称:angular,代码行数:32,代码来源:generator.ts

示例2: generate

  generate(genFilePath: string, readFile: (fileName: string) => ts.SourceFile | null): ts.SourceFile
      |null {
    const originalPath = this.map.get(genFilePath) !;
    const original = readFile(originalPath);
    if (original === null) {
      return null;
    }

    const relativePathToSource =
        './' + path.posix.basename(original.fileName).replace(TS_DTS_SUFFIX, '');
    // Collect a list of classes that need to have factory types emitted for them. This list is
    // overly broad as at this point the ts.TypeChecker hasn't been created, and can't be used to
    // semantically understand which decorated types are actually decorated with Angular decorators.
    //
    // The exports generated here are pruned in the factory transform during emit.
    const symbolNames = original
                            .statements
                            // Pick out top level class declarations...
                            .filter(ts.isClassDeclaration)
                            // which are named, exported, and have decorators.
                            .filter(
                                decl => isExported(decl) && decl.decorators !== undefined &&
                                    decl.name !== undefined)
                            // Grab the symbol name.
                            .map(decl => decl.name !.text);

    let sourceText = '';
    if (symbolNames.length > 0) {
      // For each symbol name, generate a constant export of the corresponding NgFactory.
      // This will encompass a lot of symbols which don't need factories, but that's okay
      // because it won't miss any that do.
      const varLines = symbolNames.map(
          name => `export const ${name}NgFactory = new i0.ɵNgModuleFactory(${name});`);
      sourceText = [
        // This might be incorrect if the current package being compiled is Angular core, but it's
        // okay to leave in at type checking time. TypeScript can handle this reference via its path
        // mapping, but downstream bundlers can't. If the current package is core itself, this will
        // be replaced in the factory transformer before emit.
        `import * as i0 from '@angular/core';`,
        `import {${symbolNames.join(', ')}} from '${relativePathToSource}';`,
        ...varLines,
      ].join('\n');
    }

    // Add an extra export to ensure this module has at least one. It'll be removed later in the
    // factory transformer if it ends up not being needed.
    sourceText += '\nexport const ɵNonEmptyModule = true;';

    const genFile = ts.createSourceFile(
        genFilePath, sourceText, original.languageVersion, true, ts.ScriptKind.TS);
    if (original.moduleName !== undefined) {
      genFile.moduleName =
          generatedModuleName(original.moduleName, original.fileName, '.ngfactory');
    }
    return genFile;
  }
开发者ID:matsko,项目名称:angular,代码行数:56,代码来源:factory_generator.ts

示例3: getUpdateFile

 async getUpdateFile(versionInfo: UpdateInfo): Promise<FileInfo> {
   const basePath = this.getBasePath()
   // space is not supported on GitHub
   const name = path.posix.basename(versionInfo.path).replace(/ /g, "-")
   return {
     name: name,
     url: `https://github.com${basePath}/download/v${versionInfo.version}/${name}`,
     sha2: versionInfo.sha2,
   }
 }
开发者ID:Icenium,项目名称:electron-builder,代码行数:10,代码来源:GitHubProvider.ts

示例4: getFileList

    return getFileList(updateInfo).map(it => {
      const name = path.posix.basename(it.url).replace(/ /g, "-")
      const asset = updateInfo.assets.find(it => it != null && it.name === name)
      if (asset == null) {
        throw newError(`Cannot find asset "${name}" in: ${JSON.stringify(updateInfo.assets, null, 2)}`, "ERR_UPDATER_ASSET_NOT_FOUND")
      }

      return {
        url: new URL(asset.url),
        info: it,
      }
    })
开发者ID:ledinhphuong,项目名称:electron-builder,代码行数:12,代码来源:PrivateGitHubProvider.ts

示例5: copyToAppDir

export async function copyToAppDir(folderName: string, inputFilePath: string, fileType: availableFileTypes): Promise<string> {
  if (! await exists(inputFilePath)) {
    throw new Error('The file does not exist: ' + inputFilePath)
  } else if (await isDirectory(inputFilePath)) {
    throw new Error('You can only store files, no directories')
  }

  const targetFolder = await ensureFolderExists(await getFilePath(folderName, fileType))

  const filename = posix.basename(inputFilePath)
  const targetFilePath = `${targetFolder}/${encode(filename)}`

  return await copyFile(inputFilePath, targetFilePath)
}
开发者ID:haimich,项目名称:billy,代码行数:14,代码来源:fileProvider.ts

示例6: getUpdateFile

  async getUpdateFile(versionInfo: UpdateInfo): Promise<FileInfo> {
    if (isUseOldMacProvider()) {
      return versionInfo as any
    }

    // space is not supported on GitHub
    const name = versionInfo.githubArtifactName || path.posix.basename(versionInfo.path).replace(/ /g, "-")
    return {
      name,
      url: formatUrl({path: this.getBaseDownloadPath(versionInfo.version, name), ...this.baseUrl} as any),
      sha2: versionInfo.sha2,
      sha512: versionInfo.sha512,
    }
  }
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:14,代码来源:GitHubProvider.ts

示例7: hasMetadataFile

// TODO - consider nested node_modules

/**
 * Check whether the given folder needs to be included in the ngcc compilation.
 * We do not care about folders that are:
 *
 * - symlinks
 * - node_modules
 * - do not contain a package.json
 * - do not have a typings property in package.json
 * - do not have an appropriate metadata.json file
 *
 * @param folderPath The absolute path to the folder.
 */
function hasMetadataFile(folderPath: string): boolean {
  const folderName = path.basename(folderPath);
  if (folderName === 'node_modules' || lstatSync(folderPath).isSymbolicLink()) {
    return false;
  }
  const packageJsonPath = path.join(folderPath, 'package.json');
  if (!existsSync(packageJsonPath)) {
    return false;
  }
  const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf8'));
  if (!packageJson.typings) {
    return false;
  }
  // TODO: avoid if packageJson contains built marker
  const metadataPath =
      path.join(folderPath, packageJson.typings.replace(/\.d\.ts$/, '.metadata.json'));
  return existsSync(metadataPath);
}
开发者ID:DeepanParikh,项目名称:angular,代码行数:32,代码来源:main.ts

示例8: getUpdateFile

  async getUpdateFile(versionInfo: UpdateInfo): Promise<FileInfo> {
    if (isUseOldMacProvider()) {
      return versionInfo as any
    }

    // space is not supported on GitHub
    const name = versionInfo.githubArtifactName || path.posix.basename(versionInfo.path).replace(/ /g, "-")
    const result: FileInfo = {
      name,
      url: newUrlFromBase(this.getBaseDownloadPath(versionInfo.version, name), this.baseUrl).href,
      sha512: versionInfo.sha512,
    }

    const packages = versionInfo.packages
    const packageInfo = packages == null ? null : (packages[process.arch] || packages.ia32)
    if (packageInfo != null) {
      result.packageInfo = {
        ...packageInfo,
        file: newUrlFromBase(this.getBaseDownloadPath(versionInfo.version, packageInfo.file), this.baseUrl).href,
      }
    }
    return result
  }
开发者ID:jwheare,项目名称:electron-builder,代码行数:23,代码来源:GitHubProvider.ts

示例9: getModuleId

export function getModuleId(url: string) {
  const baseName = path.basename(url);
  const lastDotIndex = baseName.lastIndexOf('.');
  const mainName = baseName.substring(0, lastDotIndex);
  return dashToCamelCase(mainName);
}
开发者ID:,项目名称:,代码行数:6,代码来源:

示例10:

		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


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