Make CI run cross-platform (#295)
This commit is contained in:
@@ -11,6 +11,7 @@ import { eq } from "drizzle-orm";
|
||||
import git from "isomorphic-git";
|
||||
import { getGitAuthor } from "../utils/git_author";
|
||||
import { ImportAppParams, ImportAppResult } from "../ipc_types";
|
||||
import { copyDirectoryRecursive } from "../utils/file_utils";
|
||||
|
||||
const logger = log.scope("import-handlers");
|
||||
const handle = createLoggedHandler(logger);
|
||||
@@ -88,11 +89,10 @@ export function registerImportHandlers() {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
// Copy the app folder to the Dyad apps directory, excluding node_modules
|
||||
await fs.cp(sourcePath, destPath, {
|
||||
recursive: true,
|
||||
filter: (source) => !source.includes("node_modules"),
|
||||
});
|
||||
// Copy the app folder to the Dyad apps directory.
|
||||
// Why not use fs.cp? Because we want stable ordering for
|
||||
// tests.
|
||||
await copyDirectoryRecursive(sourcePath, destPath);
|
||||
|
||||
const isGitRepo = await fs
|
||||
.access(path.join(destPath, ".git"))
|
||||
|
||||
@@ -39,13 +39,19 @@ export async function copyDirectoryRecursive(
|
||||
) {
|
||||
await fsPromises.mkdir(destination, { recursive: true });
|
||||
const entries = await fsPromises.readdir(source, { withFileTypes: true });
|
||||
// Why do we sort? This ensures stable ordering of files across platforms
|
||||
// which is helpful for tests (and has no practical downsides).
|
||||
entries.sort();
|
||||
|
||||
for (const entry of entries) {
|
||||
const srcPath = path.join(source, entry.name);
|
||||
const destPath = path.join(destination, entry.name);
|
||||
|
||||
if (entry.isDirectory()) {
|
||||
await copyDirectoryRecursive(srcPath, destPath);
|
||||
// Exclude node_modules directories
|
||||
if (entry.name !== "node_modules") {
|
||||
await copyDirectoryRecursive(srcPath, destPath);
|
||||
}
|
||||
} else {
|
||||
await fsPromises.copyFile(srcPath, destPath);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user