How to use the upath.dirname function in upath

To help you get started, we’ve selected a few upath 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 ryanelian / instapack / src / SassBuildTool.ts View on Github external
inline: false,
                prev: false
            };
        }

        const postcssResult = await postcss([
            autoprefixer()
        ]).process(sassResult.css, postcssOptions);

        const result: CssBuildResult = {
            css: postcssResult.css
        };

        if (this.variables.sourceMap && sassResult.map && postcssResult.map) {
            const sm2 = postcssResult.map.toJSON();
            const abs = upath.resolve(upath.dirname(virtualPostcssOutputPath), sm2.sources[0]);
            // console.log(abs);

            sm2.sources[0] = '/' + upath.relative(this.variables.root, abs);
            // console.log(sm2.sources);
            // console.log(sm2.file);

            result.map = mergeSourceMap(sassResult.map, sm2);
            /*
            => Found "merge-source-map@1.1.0"
            info Reasons this module exists
            - Hoisted from "vue-loader#@vue#component-compiler-utils#merge-source-map"
            */
        }

        return result;
    }
github GoogleChrome / workbox / packages / workbox-build / src / inject-manifest.js View on Github external
replaceString: manifestString,
      searchString: options.injectionPoint,
    });

    filesToWrite[options.swDest] = source;
    filesToWrite[sourcemapDestPath] = map;
  } else {
    // If there's no sourcemap associated with swSrc, a simple string
    // replacement will suffice.
    filesToWrite[options.swDest] = swFileContents.replace(
        globalRegexp, manifestString);
  }

  for (const [file, contents] of Object.entries(filesToWrite)) {
    try {
      await fse.mkdirp(upath.dirname(file));
    } catch (error) {
      throw new Error(errors['unable-to-make-injection-directory'] +
        ` '${error.message}'`);
    }

    await fse.writeFile(file, contents);
  }

  return {
    count,
    size,
    warnings,
    filePaths: Object.keys(filesToWrite),
  };
}
github aurelia / webpack-plugin / dist / build-resources.js View on Github external
function getPackageMainDir(packagePath) {
  var packageJson = getPackageJson(packagePath);
  if (!packageJson) {
    console.error('Unable to read the file: ' + packagePath);
    return null;
  }
  var packageMain = packageJson.aurelia && packageJson.aurelia.main && packageJson.aurelia.main['native-modules'] || packageJson.main || packageJson.browser;
  return packageMain ? path.dirname(path.join(packagePath, packageMain)) : null;
}
github jus / jus / lib / plugins / stylesheetSTYL.js View on Github external
render(context, done) {
    let output

    if (this.isStylus) {
       output = stylus(this.input)
        .set('filename', this.path.full)
        .set('paths', [path.dirname(this.path.full)])
        .render()
      return done(null, output)
    }

    return done(null, this.input)
  }
github pingyhq / pingy-cli / packages / compile / lib / baby-tolk.js View on Github external
function replaceExt(npath, ext) {
  if (typeof npath !== 'string') {
    return npath;
  }

  if (npath.length === 0) {
    return npath;
  }

  const nFileName = Path.basename(npath, pathCompleteExtname(npath)) + ext;
  return Path.join(Path.dirname(npath), nFileName);
}
github qooxdoo / qooxdoo-compiler / source / class / qx / tool / cli / commands / Command.js View on Github external
}
      let compileConfig = await qx.tool.config.Compile.getInstance().load();
      let qxpath = false;
      let appPath = await this.getApplicationPath();
      let libraries = compileConfig.getValue("libraries");
      if (libraries) {
        for (let somepath of libraries) {
          let manifestPath = somepath;
          if (!path.isAbsolute(somepath)) {
            manifestPath = path.join(appPath, manifestPath);
          }
          manifestPath = path.join(manifestPath, qx.tool.config.Manifest.config.fileName);
          let manifest = await qx.tool.utils.Json.loadJsonAsync(manifestPath);
          try {
            if (manifest.provides && manifest.provides.namespace === "qx") {
              qxpath = path.dirname(manifestPath);
              return qxpath;
            }
          } catch (e) {
            qx.tool.compiler.Console.warn(`Invalid manifest file ${manifestPath}.`);
          }
        }
      }
      return this.getGlobalQxPath();
    },
github willmendesneto / update-yeoman-generator / lib / util.js View on Github external
removeFilesInDirectory: filePath => {
    fs.unlinkSync(filePath);
    let folder = upath.dirname(filePath);
    while (fs.readdirSync(folder).length === 0) {
      fs.rmdirSync(folder);
      folder = upath.parse(folder).dir;
    }
  },

upath

A proxy to `path`, replacing `\` with `/` for all results (supports UNC paths) & new methods to normalize & join keeping leading `./` and add, change, default, trim file extensions.

MIT
Latest version published 4 years ago

Package Health Score

67 / 100
Full package analysis