Skip to content

Commit

Permalink
Fix issues with removing artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
Lbqds committed Jul 25, 2024
1 parent bfc599c commit 8de46b8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/cli/src/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,17 @@ export class ProjectArtifact {

function removeOldArtifacts(dir: string, sourceFiles: SourceInfo[]) {
const files = fs.readdirSync(dir)
const hasConstant = sourceFiles.find((s) => s.type === SourceKind.Constants) !== undefined
const hasStruct = sourceFiles.find((s) => s.type === SourceKind.Struct) !== undefined
files.forEach((file) => {
const filePath = path.join(dir, file)
const stat = fs.statSync(filePath)
if (stat.isDirectory()) {
removeOldArtifacts(filePath, sourceFiles)
} else if (filePath.endsWith(Project.constantArtifactFileName)) {
if (!hasConstant) fs.unlinkSync(filePath)
} else if (filePath.endsWith(Project.structArtifactFileName)) {
if (!hasStruct) fs.unlinkSync(filePath)
} else if (filePath.endsWith('.ral.json') || filePath.endsWith('.ral')) {
const filename = path.basename(filePath)
const artifactName = filename.slice(0, filename.indexOf('.'))
Expand Down

0 comments on commit 8de46b8

Please sign in to comment.