当前位置: 首页>>代码示例>>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;未经允许,请勿转载。