How to use the umi-utils.winPath function in umi-utils

To help you get started, we’ve selected a few umi-utils 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 umijs / umi / packages / umi-build-dev / src / plugins / commands / block / addBlock.ts View on Github external
subBlocks.map((block: string) => {
          const subBlockPath = join(ctx.templateTmpDirPath, block);
          debug(`subBlockPath: ${subBlockPath}`);
          return new BlockGenerator(args._.slice(2), {
            sourcePath: subBlockPath,
            path: isPageBlock ? generator.path : join(generator.path, generator.blockFolderName),
            // eslint-disable-next-line
            blockName: getNameFromPkg(require(join(subBlockPath, 'package.json'))),
            isPageBlock: false,
            dryRun,
            env: {
              cwd: api.cwd,
            },
            routes: api.config.routes,
            resolved: winPath(__dirname),
          }).run();
        }),
      );
github umijs / umi / packages / umi-build-dev / src / plugins / commands / block / ui / util.ts View on Github external
.map((fileName: string) => {
      const status = fs.statSync(join(path, fileName));
      // 是文件夹 并且不已 . 开头, 且最深三层
      if (status.isDirectory() && fileName.indexOf('.') !== 0 && depth < 3) {
        const absPath = winPath(join(path, fileName));
        const absPagePath = winPath(join(parentPath, fileName));
        const children = getFolderTreeData(absPath, absPagePath, depth + 1);
        if (children && children.length > 0) {
          return {
            key: absPagePath,
            title: fileName,
            value: absPagePath,
            children,
          };
        }
        return { title: fileName, value: absPagePath, key: absPagePath };
      }
      return undefined;
    })
    .filter(obj => obj);
github umijs / umi / packages / umi-core / src / getUserConfig.ts View on Github external
export function getConfigFile(cwd) {
  const files = process.env.UMI_CONFIG_FILE
    ? process.env.UMI_CONFIG_FILE.split(',').filter(v => v && v.trim())
    : ['.umirc.ts', '.umirc.js', 'config/config.ts', 'config/config.js'];
  const validFiles = files.filter(f => existsSync(join(cwd, f)));
  assert(
    validFiles.length <= 1,
    `Multiple config files (${validFiles.join(', ')}) were detected, please keep only one.`,
  );
  if (validFiles[0]) {
    return winPath(join(cwd, validFiles[0]));
  }
}
github umijs / umi / packages / umi-mock / src / createMiddleware.js View on Github external
paths.some(path => {
          return winPath(file).indexOf(path) > -1;
        })
      ) {
github umijs / umi / packages / umi-build-dev / src / plugins / 404 / index.js View on Github external
api.modifyRoutes(memo => {
      const notFoundRoute = {
        component: `
() => React.createElement(require('${winPath(
          join(__dirname, 'NotFound.js'),
        )}').default, { pagesPath: '${paths.pagesPath}', hasRoutesInConfig: ${!!config.routes} })
        `.trim(),
      };
      const routes = cloneDeep(memo);

      function addNotFound(_route) {
        if (!_route.routes) {
          return;
        }
        _route.routes.forEach(_r => addNotFound(_r));
        _route.routes.push(notFoundRoute);
      }

      routes.forEach(r => addNotFound(r));
      routes.push(notFoundRoute);
github ant-design / ant-design-pro-cli / src / i18n / getLocalFileList.js View on Github external
const arrayList = getLocaleFileList(absSrcPath, absPagesPath)[locale].map(({ path }) =>
    winPath(path),
  );
github onpaik / umi-lib-paik / packages / umi-plugin-locale-paik / src / translate / index.js View on Github external
async function generatePublicFile(...arg){
  const [ file, absSrcPath, support, collectData,spinner  ] = arg;
  let _tempData = collectData;
  const { name, path } = file;
  const dynamicName = getDynamicName(name);
  const tempPublicPath = winPath(`${absSrcPath.replace(/src\//,'public/.lang')}`);
  const tempFilePath = winPath(`${tempPublicPath}/${name}`);
  const ext = getExt(path); 
  _tempData= {
    [dynamicName]:{
      ...(collectData[dynamicName] || {}),
    }
  }
  if(ext.match(/^(j|t)s$/i)){
    await rimraf.sync(tempPublicPath);
    const { code } = transformFileSync(path, getBabelConfig());
    await writeFile(tempFilePath,code);
    delete require.cache[tempFilePath]
    const content = await require(tempFilePath).default;
    await rimraf.sync(tempPublicPath);
    const data = await transLatePublic(content,support,path,spinner);
    _tempData[dynamicName] = deepmerge(data,_tempData[dynamicName])
github umijs / umi / packages / umi-mock / src / getPaths.js View on Github external
export default function(cwd) {
  const winCwd = winPath(cwd);
  const absMockPath = winPath(join(winCwd, 'mock'));
  const absConfigPath = winPath(join(winCwd, '.umirc.mock.js'));
  const absConfigPathWithTS = winPath(join(winCwd, '.umirc.mock.ts'));
  return {
    absMockPath,
    absConfigPath,
    absConfigPathWithTS,
  };
}
github umijs / umi / packages / umi-build-dev / src / FilesGenerator.js View on Github external
importsAhead: importsToStr(
        this.service.applyPlugins('addEntryImportAhead', {
          initialValue: [],
        }),
      ).join('\n'),
      polyfillImports: importsToStr(
        this.service.applyPlugins('addEntryPolyfillImports', {
          initialValue: [],
        }),
      ).join('\n'),
      moduleBeforeRenderer,
      render: initialRender,
      plugins,
      validKeys,
      htmlTemplateMap: htmlTemplateMap.join('\n'),
      findRoutePath: winPath(require.resolve('./findRoute')),
    });
    writeContent(paths.absLibraryJSPath, prettierFile(`${entryContent.trim()}\n`));
  }