axios-miniprogram/scripts/utils.js

15 lines
644 B
JavaScript
Raw Permalink Normal View History

2023-03-23 20:09:00 +08:00
import path from 'node:path';
import { createRequire } from 'node:module';
import { fileURLToPath } from 'node:url';
import { execSync } from 'node:child_process';
export const __dirname = fileURLToPath(new URL('../', import.meta.url));
export const require = createRequire(import.meta.url);
2023-03-24 19:41:17 +08:00
export const pkgPath = path.resolve(__dirname, 'package.json');
export const distPath = path.resolve(__dirname, 'dist');
2023-03-23 20:09:00 +08:00
export const exec = (command, options) =>
execSync(command, { stdio: 'inherit', ...(options ?? {}) });
export const getPkgJSON = () => require(pkgPath);
2023-03-25 23:31:27 +08:00
export const getFileName = (filePath) => filePath.match(/\/([^/]*)$/)[1];