當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。