How to use the is-absolute function in is-absolute

To help you get started, we’ve selected a few is-absolute examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github callumlocke / esbox / src / lib / run.js View on Github external
;

  if (error._babel) {
    console.log(
      `\nCompile error: ${fileRelative}\n` +
      excerpt({
        line, column,
        contents: fs.readFileSync(fileName),
      }) + '\n' + cc.red(message.trim())
    );
  }
  else {
    // try to determine if it's a local file (as opposed to a builtin)
    if (
      fileName && (
        isAbsolute(fileName) || (
          builtins.indexOf(path.basename(fileName, '.js')) === -1 &&
          pathExists.sync(path.resolve(cwd, fileName))
        )
      )
    ) {
      console.log(
        `\nRuntime error: ${fileRelative}\n` +
        excerpt({
          line, column,
          contents: fs.readFileSync(fileName),
        }) + '\n'
      );
    }

    console.log(
      cc.red(message.trim()) + '\n' +
github callumlocke / esbox / src / lib / readableStack.js View on Github external
return stackTrace.parse(error).map(call => {
    const fileName = call.getFileName();
    const functionName = call.getFunctionName();
    const lineNumber = call.getLineNumber();
    const columnNumber = call.getColumnNumber();

    if (isString(fileName)) {
      const absolute = isAbsolute(fileName);
      const resolvedFileName = path.resolve(cwd, fileName);

      if (
        subdir(cwd, fileName) &&
        !subdir(path.join(cwd, 'node_modules'), resolvedFileName) &&
        (absolute || (
          builtins.indexOf(path.basename(fileName, '.js')) === -1 &&
          pathExists.sync(resolvedFileName)
        ))
      ) {
        // absolute and within CWD (but not in node_modules folder)
        // - highlight this line
        return (
          (functionName ? grey('  at ') + functionName : ' ') +
          grey(' in ') + path.join('./', path.relative(cwd, fileName)) +
          (lineNumber ? grey(':' + lineNumber + ':' + columnNumber) : '')

is-absolute

Returns true if a file path is absolute. Does not rely on the path module and can be used as a polyfill for node.js native `path.isAbolute`.

MIT
Latest version published 7 years ago

Package Health Score

68 / 100
Full package analysis

Popular is-absolute functions