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


TypeScript resolve.apply方法代码示例

本文整理汇总了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;
	}
开发者ID:Bartvds,项目名称:unfunk-diff,代码行数:7,代码来源:helper.ts

示例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);
}
开发者ID:wonism,项目名称:nbind,代码行数:57,代码来源:nbind.ts

示例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;
}
开发者ID:snailuncle,项目名称:vscode-chrome-debug,代码行数:9,代码来源:testUtils.ts

示例4: getCurrentPath

function getCurrentPath(fileName: string): string {
    var pathArray = fileName.split(sep);
    pathArray.unshift('/');
    pathArray.pop();
    return resolve.apply(null, pathArray);
}
开发者ID:tangshengfei,项目名称:vscode-autofilename,代码行数:6,代码来源:extension.ts

示例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() {
开发者ID:PolymerLabs,项目名称:polylint,代码行数:67,代码来源:cli.ts

示例6: normal

export function normal(...args: string[]): string {
  return path.resolve.apply(path, basePath.concat(sanitize(args)));
}
开发者ID:Deathspike,项目名称:mangarack,代码行数:3,代码来源:path.ts

示例7: hidden

export function hidden(...args: string[]): string {
  return path.resolve.apply(path, basePath.concat('.mrprivate').concat(sanitize(args)));
}
开发者ID:Deathspike,项目名称:mangarack,代码行数:3,代码来源:path.ts

示例8: getFixturePath

	export function getFixturePath(...args:string[]):string {
		args.unshift('test', 'fixtures');
		return path.resolve.apply(path, args);
	}
开发者ID:Bartvds,项目名称:unfunk-diff,代码行数:4,代码来源:helper.ts


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