• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript path.isAbsolute函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中path.isAbsolute函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isAbsolute函数的具体用法?TypeScript isAbsolute怎么用?TypeScript isAbsolute使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了isAbsolute函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: it

 it('should set src dir from incorrect config case', () => {
   (config as any).SrcDIR = () => 'myapp';
   validateConfig(config);
   expect(path.basename(config.srcDir)).toBe('myapp');
   expect(path.isAbsolute(config.srcDir)).toBe(true);
 });
开发者ID:franktopel,项目名称:stencil,代码行数:6,代码来源:validate-paths.spec.ts


示例2: start

/**
 * Parses the options and starts the selenium standalone server.
 * @param options
 */
function start(options: Options) {
  let osType = os.type();
  let binaries = FileManager.setupBinaries();
  let seleniumPort = options[Opt.SELENIUM_PORT].getString();
  let outputDir = Config.getSeleniumDir();
  if (options[Opt.OUT_DIR].getString()) {
    if (path.isAbsolute(options[Opt.OUT_DIR].getString())) {
      outputDir = options[Opt.OUT_DIR].getString();
    } else {
      outputDir = path.resolve(Config.getBaseDir(), options[Opt.OUT_DIR].getString());
    }
  }

  try {
    // check if folder exists
    fs.statSync(outputDir).isDirectory();
  } catch (e) {
    // if the folder does not exist, quit early.
    logger.warn('the out_dir path ' + outputDir + ' does not exist, run webdriver-manager update');
    return;
  }

  let chromeLogs: string = null;
  if (options[Opt.CHROME_LOGS].getString()) {
    if (path.isAbsolute(options[Opt.CHROME_LOGS].getString())) {
      chromeLogs = options[Opt.CHROME_LOGS].getString();
    } else {
      chromeLogs = path.resolve(Config.getBaseDir(), options[Opt.CHROME_LOGS].getString());
    }
  }
  binaries[StandAlone.id].versionCustom = options[Opt.VERSIONS_STANDALONE].getString();
  binaries[ChromeDriver.id].versionCustom = options[Opt.VERSIONS_CHROME].getString();
  if (options[Opt.VERSIONS_IE]) {
    binaries[IEDriver.id].versionCustom = options[Opt.VERSIONS_IE].getString();
  }
  let downloadedBinaries = FileManager.downloadedBinaries(outputDir);

  if (downloadedBinaries[StandAlone.id] == null) {
    logger.error(
        'Selenium Standalone is not present. Install with ' +
        'webdriver-manager update --standalone');
    process.exit(1);
  }
  let args: string[] = ['-jar', path.join(outputDir, binaries[StandAlone.id].filename())];
  if (seleniumPort) {
    args.push('-port', seleniumPort);
  }
  if (downloadedBinaries[ChromeDriver.id] != null) {
    args.push(
        '-Dwebdriver.chrome.driver=' +
        path.join(outputDir, binaries[ChromeDriver.id].executableFilename(osType)));
    if (chromeLogs != null) {
      args.push('-Dwebdriver.chrome.logfile=' + chromeLogs);
    }
  }
  if (downloadedBinaries[IEDriver.id] != null) {
    args.push(
        '-Dwebdriver.ie.driver=' +
        path.join(outputDir, binaries[IEDriver.id].executableFilename(osType)));
  }

  // log the command to launch selenium server
  let argsToString = '';
  for (let arg in args) {
    argsToString += ' ' + args[arg];
  }
  logger.info('java' + argsToString);

  let seleniumProcess = spawnCommand('java', args);
  logger.info('seleniumProcess.pid: ' + seleniumProcess.pid);
  seleniumProcess.on('exit', (code: number) => {
    logger.info('Selenium Standalone has exited with code ' + code);
    process.exit(code);
  });
  process.stdin.resume();
  process.stdin.on('data', (chunk: Buffer) => {
    logger.info('Attempting to shut down selenium nicely');
    var port = seleniumPort || '4444';
    http.get('http://localhost:' + port + '/selenium-server/driver/?cmd=shutDownSeleniumServer');
  });
  process.on('SIGINT', () => {
    logger.info('Staying alive until the Selenium Standalone process exits');
  });
}
开发者ID:avatar-7,项目名称:webdriver-manager,代码行数:88,代码来源:start.ts


示例3: pathJoin

 Object.keys(config[dirsKey]).forEach((key) => {
     if (!isAbsolute(config[dirsKey][key])) {
         config[dirsKey][key] = pathJoin(appRoot, config[dirsKey][key]);
     }
 });
开发者ID:ehanlon,项目名称:azure-managed-automate,代码行数:5,代码来源:deploy.ts


示例4: parseAst


//.........这里部分代码省略.........
              source.value = getExactedNpmFilePath({
                npmName: value,
                sourceFilePath,
                filePath,
                isProduction,
                npmConfig,
                buildAdapter,
                root: appPath,
                npmOutputDir,
                compileInclude,
                env: projectConfig.env || {},
                uglify: projectConfig!.plugins!.uglify || {},
                babelConfig: projectConfig!.plugins!.babel || {}
              })
            } else {
              source.value = value
            }
          }
        }
      } else if (CSS_EXT.indexOf(path.extname(value)) !== -1 && specifiers.length > 0) { // 对 使用 import style from './style.css' 语法引入的做转化处理
        printLog(processTypeEnum.GENERATE, '替换代码', `为文件 ${sourceFilePath} 生成 css modules`)
        const styleFilePath = path.join(path.dirname(sourceFilePath), value)
        const styleCode = fs.readFileSync(styleFilePath).toString()
        const result = processStyleUseCssModule({
          css: styleCode,
          filePath: styleFilePath
        })
        const tokens = result.root.exports || {}
        const cssModuleMapFile = createCssModuleMap(styleFilePath, tokens)
        astPath.node.source = t.stringLiteral(astPath.node.source.value.replace(path.basename(styleFilePath), path.basename(cssModuleMapFile)))
        if (styleFiles.indexOf(styleFilePath) < 0) { // add this css file to queue
          styleFiles.push(styleFilePath)
        }
      } else if (path.isAbsolute(value)) {
        printLog(processTypeEnum.ERROR, '引用文件', `文件 ${sourceFilePath} 中引用 ${value} 是绝对路径!`)
      }
    },

    CallExpression (astPath) {
      const node = astPath.node
      const callee = node.callee as (t.Identifier | t.MemberExpression)
      if (t.isMemberExpression(callee)) {
        if (taroImportDefaultName && (callee.object as t.Identifier).name === taroImportDefaultName && (callee.property as t.Identifier).name === 'render') {
          astPath.remove()
        }
      } else if (callee.name === 'require') {
        const args = node.arguments as t.StringLiteral[]
        let value = args[0].value
        const parentNode = astPath.parentPath.parentPath.node as t.VariableDeclaration
        if (isAliasPath(value, pathAlias)) {
          value = replaceAliasPath(sourceFilePath, value, pathAlias)
          args[0].value = value
        }
        if (isNpmPkg(value) && !isQuickAppPkg(value) && !notExistNpmList.has(value)) {
          if (value === taroJsComponents) {
            if (isQuickApp) {
              if (parentNode.declarations.length === 1 && parentNode.declarations[0].init) {
                const id = parentNode.declarations[0].id
                if (id.type === 'ObjectPattern') {
                  const properties = id.properties as any
                  properties.forEach(p => {
                    if (p.type === 'ObjectProperty' && p.value.type === 'Identifier') {
                      taroSelfComponents.add(_.kebabCase(p.value.name))
                    }
                  })
                }
开发者ID:YangShaoQun,项目名称:taro,代码行数:67,代码来源:astProcess.ts


示例5: src2relative

/**
 * 转换相对地址
 *
 * @param {string} src
 * @returns
 */
function src2relative (src: string) {
  if (!path.isAbsolute(src)) {
    return src
  }
  return path.relative(config.cwd, src)
}
开发者ID:bbxyard,项目名称:bbxyard,代码行数:12,代码来源:cache.ts


示例6: async

  lint: async (textEditor: TextEditor): Promise<LintResult> => {
    const filePath = textEditor.getPath();

    if (!filePath) {
      // The current TextEditor has no path associated with it.
      return null;
    }

    const input = textEditor.getText();

    const command = atom.config.get("linter-swiftlint.swiftlintExecutablePath");
    if (!fs.existsSync(command)) {
      return null;
    }

    const parameters = ["lint", "--use-stdin"];
    let config = path.normalize(
      atom.config.get("linter-swiftlint.configurationPath")
    );

    if (filePath && !path.isAbsolute(config)) {
      config =
        atom.project
          .getDirectories()
          .filter(directory => directory.contains(filePath))
          .map(directory => directory.getFile(config).getPath())
          .find(() => true) || config; // take first item if exists
    }

    if (config && fs.existsSync(config)) {
      parameters.push("--config", config);
    }

    const additionalOptions = atom.config.get(
      "linter-swiftlint.additionalOptions"
    );
    if (additionalOptions) {
      parameters.push(additionalOptions);
    }

    const options = {
      ignoreExitCode: true,
      stdin: input,
      throwOnStderr: false
    };

    const output = await helpers.exec(command, parameters, options);

    const messages: Message[] = [];
    let match = regex.exec(output);
    while (match !== null) {
      const line = Math.max(Number.parseInt(match[1], 10) - 1, 0);
      const col = Math.max(Number.parseInt(match[2], 10) - 1, 0);
      let position: Range;
      try {
        position = helpers.generateRange(textEditor, line, col);
      } catch(e) {
        // If the position wasn't valid, just return the start of the file
        // NOTE: Ideally this would handle the error and give the user an easy
        // way to report it for eventual fixing.
        position = new Range([0, 0], [0, Number.POSITIVE_INFINITY]);
      }

      const type = match[3].toLowerCase();
      const severity =
        type === 'error' || type === 'warning' || type === 'info' ?
        type : 'error';

      messages.push({
        severity,
        excerpt: match[4],
        location: {
          file: filePath,
          position,
        }
      });

      // Pull in the next result (if any)
      match = regex.exec(output);
    }

    return messages;
  }
开发者ID:AtomLinter,项目名称:linter-swiftlint,代码行数:83,代码来源:linter-provider.ts


示例7: checkNodeImport

// Helpers
function checkNodeImport(context, request, cb) {
  if (!path.isAbsolute(request) && request.charAt(0) !== '.') {
    cb(null, 'commonjs ' + request); return;
  }
  cb();
}
开发者ID:threesquared,项目名称:3sq.re,代码行数:7,代码来源:webpack.config.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript path.join函数代码示例发布时间:2022-05-25
下一篇:
TypeScript path.format函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap