Skip to content

Commit

Permalink
feat(utils): add getRelativePath
Browse files Browse the repository at this point in the history
  • Loading branch information
liangskyli committed May 14, 2022
1 parent e98ebf2 commit 68e9463
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@ import signale from 'signale';
import createDebug from 'debug';
import colors from 'colors';

export { getAbsolutePath, prettierData, copyOptions, winPath, removeFilesSync } from './tools';
export {
getAbsolutePath,
getRelativePath,
prettierData,
copyOptions,
winPath,
removeFilesSync,
} from './tools';
export { default as getConfig } from './config';
export { address, colors, lodash, signale, createDebug };
export { default as parseRequireDeps } from './parse-require-deps/parse-require-deps';
4 changes: 4 additions & 0 deletions packages/utils/src/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ export const getAbsolutePath = (pathName: string) => {
return path.isAbsolute(pathName) ? pathName : path.join(process.cwd(), pathName);
};

export const getRelativePath = (absolutePath1: string, absolutePath2: string) => {
return path.relative(absolutePath1, absolutePath2);
};

export const prettierData = async (fileContent: string, options?: prettier.Options) => {
let configFile;
try {
Expand Down

0 comments on commit 68e9463

Please sign in to comment.