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


TypeScript path.isAbsolute函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。