How to use the upath.join 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 GoogleChrome / workbox / gulp-tasks / transpile-typescript.js View on Github external
const transpilePackage = async (packageName) => {
  try {
    // Compile TypeScript for the given project.
    // Reference the local `node_modules` version of `tsc` since on Windows
    // it will call the version in `Microsoft SDKs/TypeScript`.
    await exec(`npm run local-tsc -- -b packages/${packageName}`);

    // Mirror all `.ts` files with `.mjs` files.
    const tsFiles = await globby(`**/*.ts`, {
      cwd: path.join('packages', packageName, 'src'),
    });

    for (const tsFile of tsFiles) {
      const assetBasename = path.basename(tsFile, '.ts');
      const mjsFile = path.join('packages',
          packageName, path.dirname(tsFile), assetBasename + '.mjs');

      if (!(await fs.pathExists(mjsFile))) {
        const mjsSource = `export * from './${assetBasename}.js';`;

        // console.log({mjsFile, tsFile, assetBasename})
        fs.outputFileSync(mjsFile, mjsSource);
      }
    }
  } catch (error) {
    logHelper.error(error.stdout);
    throw error;
  }
};
github ryanelian / instapack / src / CopyBuildTool.ts View on Github external
// file or folder does not exist, is probably a glob...
                if (FastGlob.isDynamicPattern(relativeFilePath)) {
                    globs.push(relativeFilePath);
                }
            }
        }

        const assets = await FastGlob(globs, {
            cwd: libraryPath
        }); // folder/something.svg

        const commonPath = this.findCommonParentFolderPath(assets); // folder
        // console.log('COMMON PATH:', commonPath);

        for (const asset of assets) {
            const absoluteFilePath = upath.join(libraryPath, asset); // /project/node_modules/library/folder/something.svg
            const relativeFilePath = upath.relative(commonPath, asset); // something.svg
            const targetFilePath = upath.join(targetPath, relativeFilePath); // /project/wwwroot/target/something.svg
            // console.log(relativeFilePath);
            // console.log(absoluteFilePath);
            // console.log(targetFilePath);
            const task = this.tryCopyFile(absoluteFilePath, targetFilePath, overwrite);
            tasks.push(task)
        }

        const success = await Promise.all(tasks);
        return success.filter(Q => Q).length;
    }
github ryanelian / instapack / src / index.ts View on Github external
async scaffold(template: string): Promise {
        const templateFolder = upath.join(__dirname, '../templates', template);

        const exist = await fse.pathExists(templateFolder);
        if (!exist) {
            Shout.error('Unable to find new project template for:', chalk.cyan(template));
            return;
        }

        let mergedPackageJson: unknown;
        const projectPackageJsonPath = upath.join(this.projectFolder, 'package.json');
        const templatePackageJsonPath = upath.join(templateFolder, 'package.json');
        if (await fse.pathExists(projectPackageJsonPath) && await fse.pathExists(templatePackageJsonPath)) {
            // would override, should merge fields instead: instapack, dependencies, and devDependencies
            const projectPackageJson = await fse.readJson(projectPackageJsonPath);
            const templatePackageJson = await fse.readJson(templatePackageJsonPath);

            mergedPackageJson = mergePackageJson(projectPackageJson, templatePackageJson);
        }

        console.log('Initializing new project using template:', chalk.cyan(template));
        console.log('Scaffolding project into your web app...');
        await fse.copy(templateFolder, this.projectFolder);

        if (mergedPackageJson) {
            console.log(`Merging ${chalk.blue('package.json')}...`);
            await fse.writeJson(projectPackageJsonPath, mergedPackageJson, {
                spaces: 2
github qooxdoo / qooxdoo-compiler / source / class / qx / tool / cli / commands / add / Class.js View on Github external
break;
        }
      }
      if (!found) {
        throw new qx.tool.utils.Utils.UserError(`Template ${template_name} does not exist.`);
      }
      let template = await fs.readFileAsync(template_path, "utf-8");

      // handle header macro in the project root
      let header_template;
      let header_template_path = path.join(process.cwd(), "header.js");
      try {
        header_template = fs.readFileSync(header_template_path, "utf-8");
      } catch (e) {
        // if none exists, use header template in the same folder as the template itself
        header_template_path = path.join(path.dirname(template_path), "header.tmpl.js");
        try {
          header_template = fs.readFileSync(header_template_path, "utf-8");
        } catch (e) {}
      }
      if (header_template) {
        // replace template vars in header
        if (header_template_path.includes(".tmpl.js")) {
          for (let var_name in values) {
            header_template = header_template.replace(new RegExp(`\\$\{${var_name}\}`, "g"), values[var_name]);
          }
        }
        values.header = header_template;
      }

      // replace template vars
      let final_content = template;
github GoogleChrome / workbox / test / workbox-webpack-plugin / node / generate-sw.js View on Github external
it(`should support projects that bundle WASM code`, function(done) {
      const outputDir = tempy.directory();
      const srcDir = upath.join(__dirname, '..', 'static', 'wasm-project');
      const config = {
        mode: 'production',
        entry: {
          index: upath.join(srcDir, 'index.js'),
        },
        output: {
          filename: '[name].js',
          globalObject: 'self',
          path: outputDir,
        },
        plugins: [
          new WorkerPlugin(),
          new GenerateSW(),
        ],
      };
github ryanelian / instapack / bin / Settings.js View on Github external
get inputCssFolder() {
        return upath.join(this.inputFolder, 'css');
    }
    get jsEntry() {
github pingyhq / pingy-cli / packages / export / lib / helpers.js View on Github external
const getMainFile = (outputDir, sha) => {
  const files = sha.output;
  const mainFile = files[files.length - 1];
  return path.join(outputDir, mainFile);
};
github ryanelian / instapack / src / variables-factory / PathFinder.ts View on Github external
get scssGlob(): string {
        return upath.join(this.cssInputFolder, '**', '*.scss');
    }
github Skinney / elm-git-install / index.js View on Github external
function readElmJson(repoPath) {
  let elmFilePath = path.join(repoPath, 'elm.json');
  let gitDepsPath = path.join(repoPath, 'elm-git.json');

  let elmFileJson = {};
  if (fs.existsSync(elmFilePath)) {
    const elmFile = fs.readFileSync(elmFilePath, { encoding: 'utf-8' });
    elmFileJson = JSON.parse(elmFile);
  }

  let gitDepsJson = {};
  if (fs.existsSync(gitDepsPath)) {
    const gitDeps = fs.readFileSync(gitDepsPath, { encoding: 'utf-8' });
    gitDepsJson = JSON.parse(gitDeps);
  }

  return Object.assign(elmFileJson, gitDepsJson);
}
github ryanelian / instapack / src / Settings.ts View on Github external
get outputJsFile(): string {
        return upath.join(this.outputJsFolder, this.jsOut);
    }

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