forked from JaylyDev/ScriptAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.ts
More file actions
13 lines (12 loc) · 966 Bytes
/
utils.ts
File metadata and controls
13 lines (12 loc) · 966 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
import * as path from "path";
import * as fs from "fs";
// Basically a better way to say that those packages are so bad that no one uses it
// The list should not be modify by other people
import * as legacyPackages from "../legacyPackages.json";
export const scriptsPath = path.resolve(process.cwd(), 'scripts'); // readdirSync(path.resolve(cwd, 'scripts')).map(name => name.replaceAll(path.win32.sep, path.posix.sep));
export const scriptsAll = fs.readdirSync(scriptsPath).filter(file => fs.statSync(path.resolve(scriptsPath, file)).isDirectory());
export const scripts = scriptsAll.filter(script => !legacyPackages.packages.includes(script));
export const mainFilenames = ["index.ts", "index.js"];
export const readmeFilenames = ["readme.md", "readme.txt", "readme"];
export const scriptFileExtensions = ['.js', '.ts'];
export const printFilePath = (filePath: string) => filePath.replace(process.cwd() + path.sep, '').replaceAll(path.win32.sep, path.posix.sep);