Make the install faster
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import { generateKeycloakThemeResources } from "./generateKeycloakThemeResources";
|
||||
import { generateJavaStackFiles } from "./generateJavaStackFiles";
|
||||
import type { ParsedPackageJson } from "./generateJavaStackFiles";
|
||||
|
@ -1,3 +1,4 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import * as fs from "fs";
|
||||
import { join as pathJoin, basename as pathBasename } from "path";
|
||||
|
37
src/tools/crawl.ts
Normal file
37
src/tools/crawl.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
|
||||
/** List all files in a given directory return paths relative to the dir_path */
|
||||
export const crawl = (() => {
|
||||
|
||||
const crawlRec = (dir_path: string, paths: string[]) => {
|
||||
|
||||
for (const file_name of fs.readdirSync(dir_path)) {
|
||||
|
||||
const file_path = path.join(dir_path, file_name);
|
||||
|
||||
if (fs.lstatSync(file_path).isDirectory()) {
|
||||
|
||||
crawlRec(file_path, paths);
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
paths.push(file_path);
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
return function crawl(dir_path: string): string[] {
|
||||
|
||||
const paths: string[] = [];
|
||||
|
||||
crawlRec(dir_path, paths);
|
||||
|
||||
return paths.map(file_path => path.relative(dir_path, file_path));
|
||||
|
||||
}
|
||||
|
||||
})();
|
@ -2,8 +2,7 @@
|
||||
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
import { crawl } from "denoify/tools/crawl";
|
||||
import { createDirectoryIfNotExistsRecursive } from "denoify/tools/createDirectoryIfNotExistsRecursive";
|
||||
import { crawl } from "./crawl";
|
||||
|
||||
/** Apply a transformation function to every file of directory */
|
||||
export function transformCodebase(
|
||||
@ -35,16 +34,16 @@ export function transformCodebase(
|
||||
continue;
|
||||
}
|
||||
|
||||
createDirectoryIfNotExistsRecursive(
|
||||
fs.mkdirSync(
|
||||
path.dirname(
|
||||
path.join(
|
||||
destDirPath,
|
||||
file_relative_path
|
||||
)
|
||||
)
|
||||
),
|
||||
{ "recursive": true }
|
||||
);
|
||||
|
||||
|
||||
const { newFileName, modifiedSourceCode } = transformSourceCodeStringResult;
|
||||
|
||||
fs.writeFileSync(
|
||||
|
Reference in New Issue
Block a user