Skip to content

Commit

Permalink
Add debugging to figure out windows CI tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brophdawg11 committed Aug 18, 2023
1 parent ed45485 commit 8e0180a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
10 changes: 7 additions & 3 deletions packages/create-remix/__tests__/create-remix-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe("create-remix CLI", () => {
args: ["--help"],
});
expect(stdout.trim()).toMatchInlineSnapshot(`
"create-remix
"create-remix
Usage:
Expand Down Expand Up @@ -883,7 +883,7 @@ describe("create-remix CLI", () => {
expect(fse.existsSync(path.join(emptyDir, "app/root.tsx"))).toBeTruthy();
});

it("does not copy .git nor node_modules directories if they exist in the template", async () => {
it.only("does not copy .git nor node_modules directories if they exist in the template", async () => {
// Can't really commit this file into a git repo, so just create it as
// part of the test and then remove it when we're done
let templateWithIgnoredDirs = path.join(
Expand All @@ -907,7 +907,7 @@ describe("create-remix CLI", () => {
let projectDir = getProjectDir("with-git-dir");

try {
let { status, stderr } = await execCreateRemix({
let { status, stderr, stdout } = await execCreateRemix({
args: [
projectDir,
"--template",
Expand All @@ -917,6 +917,10 @@ describe("create-remix CLI", () => {
],
});

console.log("stderr");
console.log(stderr);
console.log("stdout");
console.log(stdout);
expect(stderr.trim()).toBeFalsy();
expect(status).toBe(0);
expect(fse.existsSync(path.join(projectDir, ".git"))).toBeFalsy();
Expand Down
3 changes: 2 additions & 1 deletion packages/create-remix/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ async function copyTempDirToAppDirStep(ctx: Context) {
// have node_modules/
let file = stripDirectoryFromPath(ctx.tempDir, src);
let isIgnored = IGNORED_TEMPLATE_DIRECTORIES.includes(file);
console.log("isIgnored", ctx.tempDir, src, file, isIgnored);
if (isIgnored) {
if (ctx.debug) {
debug(`Skipping copy of ${file} directory from template`);
Expand Down Expand Up @@ -625,7 +626,7 @@ async function doneStep(ctx: Context) {
if (projectDir !== "") {
let enter = [
`\n${prefix}Enter your project directory using`,
color.cyan(`cd ./${projectDir}`),
color.cyan(`cd .${path.sep}${projectDir}`),
];
let len = enter[0].length + stripAnsi(enter[1]).length;
log(enter.join(len > max ? "\n" + prefix : " "));
Expand Down
16 changes: 15 additions & 1 deletion packages/create-remix/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,21 @@ export function action(key: ActionKey, isSelect: boolean) {
}

export function stripDirectoryFromPath(dir: string, filePath: string) {
return filePath.replace(new RegExp(`^${dir}${path.sep}+`), "");
// let stripped = filePath.replace(new RegExp(`^${dir}${path.sep}+`), "");
let stripped = filePath;
if (
(dir.endsWith(path.sep) && filePath.startsWith(dir)) ||
(!dir.endsWith(path.sep) && filePath.startsWith(dir + path.sep))
) {
stripped = filePath.slice(dir.length);
if (stripped.startsWith(path.sep)) {
stripped = stripped.slice(1);
}
}
console.log(
`stripDirectoryFromPath: dir=${dir}, filePath=${filePath}, path.sep=${path.sep}, stripped=${stripped}`
);
return stripped;
}

// We do not copy these folders from templates so we can ignore them for comparisons
Expand Down

0 comments on commit 8e0180a

Please sign in to comment.