本文整理匯總了TypeScript中path.resolve.apply方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript resolve.apply方法的具體用法?TypeScript resolve.apply怎麽用?TypeScript resolve.apply使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類path.resolve
的用法示例。
在下文中一共展示了resolve.apply方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: getTmpPath
export function getTmpPath(...args:string[]):string {
args.unshift('test', 'tmp');
var dest = path.resolve.apply(path, args);
mkdirp.sync(path.dirname(dest), parseInt('0744', 8));
return dest;
}
示例2: callback
function findCompiledModule<ResultType>(
basePath: string,
specList: ModuleSpec[],
callback: FindCallback
) {
const resolvedList: string[] = [];
const ext = path.extname(basePath);
/** If basePath has a known extension, check if it's a loadable module. */
for(let spec of specList) {
if(ext == spec.ext) {
try {
spec.path = require.resolve(basePath);
// Stop if a module was found.
callback(null, spec);
return(spec);
} catch(err) {
resolvedList.push(basePath);
}
}
}
/** Try all possible subdirectories of basePath. */
for(let spec of specList) {
// Check if any possible path contains a loadable module,
// and store unsuccessful attempts.
for(let pathParts of makeModulePathList(basePath, spec.name)) {
const resolvedPath = path.resolve.apply(path, pathParts);
try {
spec.path = require.resolve(resolvedPath);
} catch(err) {
resolvedList.push(resolvedPath);
continue;
}
// Stop if a module was found.
callback(null, spec);
return(spec);
}
}
const err = new Error(
'Could not locate the bindings file. Tried:\n' +
resolvedList.join('\n')
);
(err as any).tries = resolvedList;
callback(err);
return(null);
}
示例3: pathResolve
export function pathResolve(...segments: string[]): string {
let aPath = path.resolve.apply(null, segments);
if (aPath.match(/^[A-Za-z]:/)) {
aPath = aPath[0].toLowerCase() + aPath.substr(1);
}
return aPath;
}
示例4: getCurrentPath
function getCurrentPath(fileName: string): string {
var pathArray = fileName.split(sep);
pathArray.unshift('/');
pathArray.pop();
return resolve.apply(null, pathArray);
}
示例5: Promise
//.........這裏部分代碼省略.........
}
/**
* True iff a fatal error has been reported to the end user.
* @type {boolean}
*/
var fatalFailureOccurred = false;
function prettyPrintWarning(warning) {
if (warning.fatal) {
fatalFailureOccurred = true;
}
const warningText = colors.red(warning.filename) + ":" +
warning.location.line + ":" + warning.location.column +
"\n " + colors.gray(warning.message);
logger.warn(warningText);
}
process.on('uncaughtException', function(err) {
logger.error('Uncaught exception: ', err);
fatalFailureOccurred = true;
});
process.on('unhandledRejection', function(reason, p) {
logger.error("Unhandled Rejection at: Promise ", p, " reason: ", reason);
fatalFailureOccurred = true;
});
// Find the bower dir.
var parentDirs = [];
var foundBower = false;
while (!foundBower) {
const candidatePath = path.resolve.apply(undefined, [options.root].concat(parentDirs).concat([options.bowerdir]));
if (candidatePath == path.join('/', options.bowerdir)) {
break;
}
try {
fs.statSync(candidatePath);
foundBower = true;
} catch (err) {
const currDir = path.resolve.apply(undefined, parentDirs);
parentDirs.push('..');
const parentDir = path.resolve.apply(undefined, parentDirs);
if (currDir == parentDir) {
// we've reach the root directory
break;
}
}
}
if (!foundBower) {
options.bowerdir = undefined;
} else {
options.bowerdir = path.join(path.join.apply(undefined, parentDirs), options.bowerdir);
}
var lintPromise: Promise<boolean|void|{}> = Promise.resolve(true);
var content;
if (options.stdin) {
content = "";
lintPromise = lintPromise.then(function(){
return new Promise(function(resolve, reject) {
process.stdin.setEncoding('utf8');
process.stdin.on('readable', function() {
示例6: normal
export function normal(...args: string[]): string {
return path.resolve.apply(path, basePath.concat(sanitize(args)));
}
示例7: hidden
export function hidden(...args: string[]): string {
return path.resolve.apply(path, basePath.concat('.mrprivate').concat(sanitize(args)));
}
示例8: getFixturePath
export function getFixturePath(...args:string[]):string {
args.unshift('test', 'fixtures');
return path.resolve.apply(path, args);
}