How to use the upath.changeExt 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 aurelia / webpack-plugin / src / build-resources.js View on Github external
let localSrcPath = realPath.modulePath || path.join(packagePath, relativeToDir);
    let localRelativeToDir = relativeToDir;

    if (realPath.modulePath) {
      // recursively add resources
      // TODO: async?
      getResourcesOfPackage(resources, realPath.modulePath, undefined, overrideBlock || extractBundleResourceData(resource), realPath.moduleName);

      if (moduleRootOverride[realPath.moduleName]) {
        localRelativeToDir = moduleRootOverride[realPath.moduleName];
        localSrcPath = path.join(realPath.modulePath, localRelativeToDir);
      }
    }

    // is the initially resolved file an HTML file?
    if (path.changeExt(realPath.source, 'html') !== realPath.source) {
      // .html:
      let fromPathHtml = path.addExt(fromPath, 'html');
      if (!resources[fromPathHtml]) {
        realPath = getRealPathUniversal(fromPathHtml, packagePath, relativeToDir);
        if (realPath) {
          debug(`<${path.basename(packagePath)}> ${realPath.path} => ${path.relative(packagePath, realPath.source)}`);
          resources[fromPathHtml] = Object.assign({}, resource, realPath, overrideBlock || {});
        }
      }
    }
    
    if (realPath) {
      // requested path was a html that needs analyzing for its own deps:
      let htmlResources = resolveTemplateResources(realPath.source, localSrcPath, realPath.moduleName);
      for (let htmlResource of htmlResources) {
        processFromPath(resources, htmlResource.path, htmlResource, packagePath, localRelativeToDir, overrideBlock || extractBundleResourceData(htmlResource))
github xxczaki / minifly / index.js View on Github external
comparisons: false
					},
					parse: {},
					mangle: true,
					output: {
						comments: false,
						/* eslint-disable camelcase */
						ascii_only: true
						/* eslint-enable camelcase */
					}
				});

				const path = await `${cli.flags.output}/` + file.substring(0, file.lastIndexOf('/'));
				await makeDir(path);

				fs.writeFile(`${cli.flags.output}/${upath.changeExt(file, '.min.js')}`, output.code).catch(err => {
					if (err) {
						spinner.fail('Error!\n' + err);
					}
				});
			});
		};
github aurelia / webpack-plugin / dist / build-resources.js View on Github external
debug('<' + path.basename(packagePath) + '> ' + fromPath + ' => ' + path.relative(packagePath, realPath.source));
    resources[fromPath] = (0, _assign2.default)({}, resource, realPath, overrideBlock || {});

    var localSrcPath = realPath.modulePath || path.join(packagePath, relativeToDir);
    var localRelativeToDir = relativeToDir;

    if (realPath.modulePath) {
      getResourcesOfPackage(resources, realPath.modulePath, undefined, overrideBlock || extractBundleResourceData(resource), realPath.moduleName);

      if (moduleRootOverride[realPath.moduleName]) {
        localRelativeToDir = moduleRootOverride[realPath.moduleName];
        localSrcPath = path.join(realPath.modulePath, localRelativeToDir);
      }
    }

    if (path.changeExt(realPath.source, 'html') !== realPath.source) {
      var fromPathHtml = path.addExt(fromPath, 'html');
      if (!resources[fromPathHtml]) {
        realPath = getRealPathUniversal(fromPathHtml, packagePath, relativeToDir);
        if (realPath) {
          debug('<' + path.basename(packagePath) + '> ' + realPath.path + ' => ' + path.relative(packagePath, realPath.source));
          resources[fromPathHtml] = (0, _assign2.default)({}, resource, realPath, overrideBlock || {});
        }
      }
    }

    if (realPath) {
      var htmlResources = resolveTemplateResources(realPath.source, localSrcPath, realPath.moduleName);
      for (var _iterator = htmlResources, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) {
        var _ref;

        if (_isArray) {
github xxczaki / minifly / index.js View on Github external
removeComments: true,
					collapseWhitespace: true,
					removeRedundantAttributes: true,
					useShortDoctype: true,
					removeEmptyAttributes: true,
					removeStyleLinkTypeAttributes: true,
					keepClosingSlash: true,
					minifyJS: true,
					minifyCSS: true,
					minifyURLs: true
				});

				const path = await `${cli.flags.output}/` + file.substring(0, file.lastIndexOf('/'));
				await makeDir(path);

				fs.writeFile(`${cli.flags.output}/${upath.changeExt(file, '.min.html')}`, output).catch(err => {
					if (err) {
						spinner.fail('Error!\n' + err);
					}
				});
			});
		};
github xxczaki / minifly / index.js View on Github external
await css.map(async file => {
				const contents = await fs.readFile(file, 'utf8');

				if (contents === '') {
					return;
				}

				const output = await new CleanCSS().minify(contents);

				const path = await `${cli.flags.output}/` + file.substring(0, file.lastIndexOf('/'));
				await makeDir(path);

				fs.writeFile(`${cli.flags.output}/${upath.changeExt(file, '.min.css')}`, output.styles).catch(err => {
					if (err) {
						spinner.fail('Error!\n' + err);
					}
				});
			});
		};

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