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


TypeScript module._resolveFilename函數代碼示例

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


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

示例1: _retrieveLocalVersion

  /**
   * Retrieves the local installed AngularJS Material version form the current PWD.
   */
  private static _retrieveLocalVersion(): string {
    // Create a Node module which runs at the current process working directory.
    let _cliModule = new NodeModule(process.cwd());
    _cliModule.paths = NodeModule._nodeModulePaths(process.cwd());

    // Resolve the angular-material module form the CWD module.
    let resolvedModule = path.dirname(NodeModule._resolveFilename('angular-material', _cliModule));

    let packageFile = path.join(resolvedModule, 'package.json');

    // Load the version from the local installed AngularJS Material dependency.
    return require(packageFile)['version'];
  }
開發者ID:angular,項目名稱:material-tools,代碼行數:16,代碼來源:PackageResolver.ts

示例2: loadApplicationPackage

function loadApplicationPackage (packagePath: string) {
  // Add a flag indicating app is started from default app.
  Object.defineProperty(process, 'defaultApp', {
    configurable: false,
    enumerable: true,
    value: true
  })

  try {
    // Override app name and version.
    packagePath = path.resolve(packagePath)
    const packageJsonPath = path.join(packagePath, 'package.json')
    if (fs.existsSync(packageJsonPath)) {
      let packageJson
      try {
        packageJson = require(packageJsonPath)
      } catch (e) {
        showErrorMessage(`Unable to parse ${packageJsonPath}\n\n${e.message}`)
        return
      }

      if (packageJson.version) {
        app.setVersion(packageJson.version)
      }
      if (packageJson.productName) {
        app.setName(packageJson.productName)
      } else if (packageJson.name) {
        app.setName(packageJson.name)
      }
      app.setPath('userData', path.join(app.getPath('appData'), app.getName()))
      app.setPath('userCache', path.join(app.getPath('cache'), app.getName()))
      app.setAppPath(packagePath)
    }

    try {
      Module._resolveFilename(packagePath, module, true)
    } catch (e) {
      showErrorMessage(`Unable to find Electron app at ${packagePath}\n\n${e.message}`)
      return
    }

    // Run the app.
    Module._load(packagePath, module, true)
  } catch (e) {
    console.error('App threw an error during load')
    console.error(e.stack || e)
    throw e
  }
}
開發者ID:malept,項目名稱:electron,代碼行數:49,代碼來源:main.ts

示例3:

 req.resolve = (request: string) => Module._resolveFilename(request, this)
開發者ID:illarionvk,項目名稱:dotfiles,代碼行數:1,代碼來源:factory.ts


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