How to use the upath.addExt 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 / TypeScriptSourceStore.ts View on Github external
private parseThenStoreSource(filePath: string, raw: string): boolean {
        filePath = upath.toUnix(filePath);
        let sourcePath = filePath;

        if (filePath.endsWith('.vue')) {
            sourcePath = upath.addExt(filePath, '.ts');
            raw = parseTypeScriptInVueFile(raw);
        }

        const version = this.calculateFileVersion(raw);

        const previousSource = this.sources.get(sourcePath);
        if (previousSource && previousSource.version === version) {
            return false;
        }

        // console.log(sourcePath);
        // https://github.com/Microsoft/TypeScript/blob/master/src/compiler/program.ts
        this.sources.set(sourcePath, {
            filePath: filePath,
            source: TypeScript.createSourceFile(sourcePath, raw, this.target),
            version: version
github ryanelian / instapack / src / variables-factory / ReadProjectSettings.ts View on Github external
const packageJsonPath = upath.join(folder, 'package.json');
    // console.log('Loading settings ' + chalk.cyan(json));

    const x = await tryReadPackageJsonInstapackSettings(packageJsonPath);
    // console.log(x);

    const valid = validate(x);
    if (valid === false) {
        Shout.fatal('Abort Build: Invalid instapack project settings in ' + packageJsonPath);
        console.error(validate.errors);
        throw new Error('Invalid instapack project settings!');
    }

    Object.assign(settings, x);
    settings.cssOut = upath.addExt(settings.cssOut, '.css');
    settings.jsOut = upath.addExt(settings.jsOut, '.js');

    // console.log(settings);
    return settings;
}
github aurelia / webpack-plugin / src / build-resources.js View on Github external
}
      }
    }
    
    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))
      }
    }

    // if (path.changeExt(initialRealPath.source, 'js') !== initialRealPath.source && path.changeExt(initialRealPath.source, 'ts') !== initialRealPath.source) {
    
    // .js:
    let fromPathJs = path.addExt(fromPath, 'js');
    realPath = getRealPathUniversal(fromPathJs, packagePath, relativeToDir);
    if (realPath) {
      debug(`<${path.basename(packagePath)}> ${realPath.path} => ${path.relative(packagePath, realPath.source)}`);
      resources[fromPathJs] = Object.assign({}, resource, realPath, overrideBlock || {});
    }
    // .ts:
    let fromPathTs = path.addExt(fromPath, 'ts');
    realPath = getRealPathUniversal(fromPathTs, packagePath, relativeToDir);
    if (realPath) {
      debug(`<${path.basename(packagePath)}> ${realPath.path} => ${path.relative(packagePath, realPath.source)}`);
      resources[fromPathTs] = Object.assign({}, resource, realPath, overrideBlock || {});
    }
    // .css:
    let fromPathCss = path.addExt(fromPath, 'css');
    realPath = getRealPathUniversal(fromPathCss, packagePath, relativeToDir);
    if (realPath) {
github ryanelian / instapack / bin / variables-factory / ReadProjectSettings.js View on Github external
port1: 0,
        };
        const ajv = new Ajv();
        const settingsJsonSchema = yield fse.readJson(settingsJsonSchemaPath);
        const validate = ajv.compile(settingsJsonSchema);
        const packageJsonPath = upath.join(folder, 'package.json');
        const x = yield tryReadPackageJsonInstapackSettings(packageJsonPath);
        const valid = validate(x);
        if (valid === false) {
            Shout_1.Shout.fatal('Abort Build: Invalid instapack project settings in ' + packageJsonPath);
            console.error(validate.errors);
            throw new Error('Invalid instapack project settings!');
        }
        Object.assign(settings, x);
        settings.cssOut = upath.addExt(settings.cssOut, '.css');
        settings.jsOut = upath.addExt(settings.jsOut, '.js');
        return settings;
    });
}
github ryanelian / instapack / src / variables-factory / PathFinder.ts View on Github external
get jsOutputFileName(): string {
        return upath.addExt(this.variables.jsOut, '.js');
    }
github ryanelian / instapack / bin / TypeScriptSourceStore.js View on Github external
parseThenStoreSource(filePath, raw) {
        filePath = upath.toUnix(filePath);
        let sourcePath = filePath;
        if (filePath.endsWith('.vue')) {
            sourcePath = upath.addExt(filePath, '.ts');
            raw = TypeScriptVueParser_1.parseTypeScriptInVueFile(raw);
        }
        const version = this.calculateFileVersion(raw);
        const previousSource = this.sources.get(sourcePath);
        if (previousSource && previousSource.version === version) {
            return false;
        }
        this.sources.set(sourcePath, {
            filePath: filePath,
            source: TypeScript.createSourceFile(sourcePath, raw, this.target),
            version: version
        });
        return true;
    }
    getSource(sourcePath) {
github ryanelian / instapack / src / variables-factory / PathFinder.ts View on Github external
get cssOutputFileName(): string {
        return upath.addExt(this.variables.cssOut, '.css');
    }
github ryanelian / instapack / bin / variables-factory / PathFinder.js View on Github external
get jsOutputFileName() {
        return upath.addExt(this.variables.jsOut, '.js');
    }
    get jsChunkFileName() {
github aurelia / webpack-plugin / dist / build-resources.js View on Github external
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) {
          if (_i >= _iterator.length) break;

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