本文整理汇总了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'];
}
示例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
}
}
示例3:
req.resolve = (request: string) => Module._resolveFilename(request, this)