Skip to content

Commit b607c5f

Browse files
authored
chore(ci): spread code correctly (#326)
1 parent de1d7ed commit b607c5f

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

scripts/ci/codegen/spreadGeneration.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
/* eslint-disable no-console */
2+
import { copy } from 'fs-extra';
3+
24
import {
5+
emptyDirExceptForDotGit,
36
gitBranchExists,
47
gitCommit,
58
LANGUAGES,
@@ -71,7 +74,8 @@ async function spreadGeneration(): Promise<void> {
7174
});
7275

7376
const clientPath = toAbsolutePath(getLanguageFolder(lang));
74-
await run(`cp -r ${clientPath}/ ${tempGitDir}`);
77+
await emptyDirExceptForDotGit(tempGitDir);
78+
await copy(clientPath, tempGitDir, { preserveTimestamps: true });
7579

7680
await configureGitHubAuthor(tempGitDir);
7781
await run(`git add .`, { cwd: tempGitDir });

scripts/common.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import path from 'path';
33

44
import execa from 'execa'; // https://github.com/sindresorhus/execa/tree/v5.1.1
55
import { hashElement } from 'folder-hash';
6+
import { remove } from 'fs-extra';
67

78
import openapitools from '../openapitools.json';
89

@@ -280,3 +281,11 @@ export async function buildCustomGenerators(verbose: boolean): Promise<void> {
280281
export async function gitBranchExists(branchName: string): Promise<boolean> {
281282
return Boolean(await run(`git ls-remote --heads origin ${branchName}`));
282283
}
284+
285+
export async function emptyDirExceptForDotGit(dir: string): Promise<void> {
286+
for (const file of await fsp.readdir(dir)) {
287+
if (file !== '.git') {
288+
await remove(path.resolve(dir, file));
289+
}
290+
}
291+
}

scripts/release/process-release.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
/* eslint-disable no-console */
22
import fsp from 'fs/promises';
3-
import path from 'path';
43

54
import dotenv from 'dotenv';
65
import execa from 'execa';
7-
import { copy, remove } from 'fs-extra';
6+
import { copy } from 'fs-extra';
87
import semver from 'semver';
98
import type { ReleaseType } from 'semver';
109

@@ -16,6 +15,7 @@ import {
1615
exists,
1716
getGitHubUrl,
1817
gitCommit,
18+
emptyDirExceptForDotGit,
1919
} from '../common';
2020
import { getLanguageFolder } from '../config';
2121

@@ -127,14 +127,6 @@ async function updateOpenApiTools(
127127
);
128128
}
129129

130-
async function emptyDirExceptForDotGit(dir: string): Promise<void> {
131-
for (const file of await fsp.readdir(dir)) {
132-
if (file !== '.git') {
133-
await remove(path.resolve(dir, file));
134-
}
135-
}
136-
}
137-
138130
async function updateChangelog({
139131
lang,
140132
issueBody,

0 commit comments

Comments
 (0)