Skip to content

Commit

Permalink
🦄 refactor: Move dir creation above
Browse files Browse the repository at this point in the history
  • Loading branch information
caoccao committed Mar 6, 2024
1 parent 8509643 commit a176f20
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/swc4j_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ jobs:
cargo build -r
deno run --allow-all ../scripts/ts/copy_swc4j_lib.ts -a ${{ matrix.arch }}
- name: Upload the Artifact
uses: actions/upload-artifact@v4
with:
name: swc4j-${{ matrix.os }}-${{ matrix.arch }}-${{ env.SWC4J_VERSION }}
path: src/main/resources/*${{ matrix.ext }}

- name: Setup JDK 8
uses: actions/setup-java@v4
with:
Expand All @@ -79,6 +73,12 @@ jobs:
run: |
gradle build test --rerun-tasks --debug
- name: Upload the Artifact
uses: actions/upload-artifact@v4
with:
name: swc4j-${{ matrix.os }}-${{ matrix.arch }}-${{ env.SWC4J_VERSION }}
path: src/main/resources/*${{ matrix.ext }}

build_swc4j_jar:
needs: [build_swc4j_lib]
name: Build swc4j Jar
Expand Down
6 changes: 3 additions & 3 deletions scripts/ts/copy_swc4j_lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ async function copy(debug: boolean = false, arch: string = 'x86_64'): Promise<nu
const scriptDirPath = path.dirname(path.fromFileUrl(import.meta.url))
const sourceDirPath = path.join(scriptDirPath, '../../rust/target', debug ? 'debug' : 'release')
const targetDirPath = path.join(scriptDirPath, '../../src/main/resources')
if (!fs.existsSync(targetDirPath)) {
Deno.mkdirSync(targetDirPath, { recursive: true });
}
for await (const { isFile, name } of Deno.readDir(sourceDirPath)) {
if (isFile) {
const parsedName = path.parse(name)
Expand All @@ -56,9 +59,6 @@ async function copy(debug: boolean = false, arch: string = 'x86_64'): Promise<nu
const sourceFilePath = path.join(sourceDirPath, name)
const targetFilePath = path.join(targetDirPath, `${osAndPrefix.prefix}${parsedName.name}-${osAndPrefix.os}-${arch}.v.${VERSION}${parsedName.ext}`)
console.info(`Copy from ${sourceFilePath} to ${targetFilePath}.`)
if (!fs.existsSync(targetDirPath)) {
Deno.mkdirSync(targetDirPath, { recursive: true });
}
fs.copySync(sourceFilePath, targetFilePath, { overwrite: true })
}
}
Expand Down

0 comments on commit a176f20

Please sign in to comment.