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


TypeScript path.resolve類代碼示例

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


在下文中一共展示了resolve類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: it

    it('should set up logging with a logfile', () => {
      sinon.spy(path, 'resolve');
      sinon.spy(fs, 'createWriteStream');
      sinon.stub(console, 'log');

      const args = {
        logfile: '/dev/null',
        disableproxy: true
      };

      expressApp(args);

      path.resolve.should.have.been.calledWith(args.logfile);
      fs.createWriteStream.should.have.been.calledOnceWith(args.logfile, { flags: 'a' });
      (console.log.should.have.been as any).calledOnceWith(`Log location: ${args.logfile}`);

      path.resolve.restore();
      fs.createWriteStream.restore();
      (console.log as any).restore();
    });
開發者ID:BitGo,項目名稱:BitGoJS,代碼行數:20,代碼來源:bitgoExpress.ts

示例5: 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

示例6: Promise

  return new Promise(function(resolve, reject) {
    // Check options and dump usage if we find problems.
    var inputsOk = true;
    var inputs = options.input;
    var policyPath = options.policy;

    if (!inputs || !inputs.length) {
      if (options['config-file'] && options['config-field']) {
        const field = options['config-field'];
        try {
          //TODO: This any is bad, but no other types work. Defn for readFileSync on fs may need updating.
          let contents:any = fs.readFileSync(options['config-file']);
          contents = JSON.parse(contents);
          if (contents[field] === undefined) {
            inputs = [];
            inputsOk = false;
          } else if (Array.isArray(contents[field])) {
            inputs = contents[field];
          } else {
            inputs = [contents[field]];
          }
        } catch (err) {
          logger.error(
              "No input specified and no '" + field + "' found in '" +
              options['config-file'] + "'!"
          );
          inputsOk = false;
        }
      }
    }

    if (options.stdin && inputs.length !== 1) {
      logger.error('Only one input supported in stdin mode');
      inputsOk = false;
    }

    if (!inputsOk) {
      logger.info(usage);
      process.exit(-1);
    }

    var jsconfPolicyPromise = Promise.resolve(null);
    if (options.policy) {
      jsconfPolicyPromise = new Promise(function (fulfill, reject) {
        fs.readFile(
          options.policy,
          { encoding: 'utf8' },
          function (err, fileContent) {
            if (err) {
              reject(err);
            } else {
              try {
                fulfill(jsconf_policy.fromRequirements(JSON.parse(fileContent)));
              } catch (ex) {
                reject(ex);
              }
            }
          });
      });
    }


    var root = options.root || process.cwd();
    // Make sure resolution has a path segment to drop.
    // According to URL rules,
    // resolving index.html relative to /foo/ produces /foo/index.html, but
    // resolving index.html relative to /foo produces /index.html
    // is different from resolving index.html relative to /foo/
    // This removes any ambiguity between URL resolution rules and file path
    // resolution which might lead to confusion.
    if (root !== '' && !/[\/\\]$/.test(root)) {
      root += path.sep;
    }


    /**
     * 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;
    });
//.........這裏部分代碼省略.........
開發者ID:PolymerLabs,項目名稱:polylint,代碼行數:101,代碼來源:cli.ts

示例7: inRoot

import * as webpack from 'webpack'
import * as path from 'path'
import * as HtmlWebpackPlugin from 'html-webpack-plugin'
import * as ForkTsCheckerNotifierWebpackPlugin from 'fork-ts-checker-notifier-webpack-plugin'
import * as ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin'
import * as ExtractTextPlugin from 'extract-text-webpack-plugin'
import * as autoprefixer from 'autoprefixer'
import * as OptimizeCssAssetsPlugin from 'optimize-css-assets-webpack-plugin'
import { CheckerPlugin } from 'awesome-typescript-loader'

import configs from '../configs'

const inRoot = path.resolve.bind(path, configs.pathBase)
const inRootSrc = (file) => inRoot(configs.pathBase, file)

const __DEV__ = configs.env === 'development'
const __PROD__ = configs.env === 'production'

const config = {
  name: 'client',
  target: 'web',
  resolve: {
    modules: ['node_modules'],
    extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
  },
  devtool: __DEV__ ? 'source-map' : false,
  entry: {
    main: [
      'babel-polyfill',
      inRootSrc('src/Render.tsx'),
    ],
開發者ID:stefaniepei,項目名稱:react-redux-scaffold,代碼行數:31,代碼來源:webpack.client.ts

示例8: normal

export function normal(...args: string[]): string {
  return path.resolve.apply(path, basePath.concat(sanitize(args)));
}
開發者ID:Deathspike,項目名稱:mangarack,代碼行數:3,代碼來源:path.ts

示例9: hidden

export function hidden(...args: string[]): string {
  return path.resolve.apply(path, basePath.concat('.mrprivate').concat(sanitize(args)));
}
開發者ID:Deathspike,項目名稱:mangarack,代碼行數:3,代碼來源:path.ts

示例10: require

import { Configuration } from "webpack";

const webpack = require("webpack");
const { CheckerPlugin } = require("awesome-typescript-loader");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
const path = require("path");

const relativePath = path.resolve.bind(path, __dirname);
const config: Configuration = {};
const isProduction = process.env.NODE_ENV === "production";

module.exports = config;

config.entry = {
  game: "./src/app/Game.ts",
  test: "./src/app/Test.ts",
  index: "./src/index.ts",
  vendor: ["phoenix", "phoenix_html"]
};

config.output = {
  path: relativePath("../priv/static"),
  filename: "js/[name].js"
};

config.plugins = [
  new CheckerPlugin(),
  new webpack.HashedModuleIdsPlugin(),
  new webpack.optimize.CommonsChunkPlugin({
    name: "vendor"
開發者ID:Dkendal,項目名稱:battle_snake_server,代碼行數:31,代碼來源:webpack.config.ts


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