Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(scaffold): events should use path relative to destination #137

Merged
merged 1 commit into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/scaffold/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@apoyo/scaffold",
"version": "0.2.0",
"version": "0.2.1",
"description": "Utils focused around creating code generators and scaffolders",
"main": "dist/index.js",
"module": "dist/index.mjs",
Expand Down
6 changes: 3 additions & 3 deletions packages/scaffold/src/actions/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class AddAction implements IScaffolderAction {
const exists = await app.destination.exists(to)

if (skipIfExists && exists) {
app.dispatch(new FileSkippedEvent(app.templates.resolve(to)))
app.dispatch(new FileSkippedEvent(app.destination.resolve(to)))
return
}

Expand All @@ -43,9 +43,9 @@ export class AddAction implements IScaffolderAction {
await app.destination.write(to, rendered)

if (exists) {
app.dispatch(new FileModifiedEvent(app.templates.resolve(to)))
app.dispatch(new FileModifiedEvent(app.destination.resolve(to)))
} else {
app.dispatch(new FileCreatedEvent(app.templates.resolve(to)))
app.dispatch(new FileCreatedEvent(app.destination.resolve(to)))
}
}
}
4 changes: 2 additions & 2 deletions packages/scaffold/src/actions/append.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ export class AppendAction implements IScaffolderAction {
const skip = skipIf ? skipIf.test(source) : false

if (skip === true || idx === -1) {
app.dispatch(new FileSkippedEvent(app.templates.resolve(to)))
app.dispatch(new FileSkippedEvent(app.destination.resolve(to)))
return
}

lines.splice(idx + 1, 0, rendered)

await app.destination.write(to, lines.join('\n'))

app.dispatch(new FileModifiedEvent(app.templates.resolve(to)))
app.dispatch(new FileModifiedEvent(app.destination.resolve(to)))
}
}
2 changes: 1 addition & 1 deletion packages/scaffold/src/actions/delete-many.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class DeleteManyAction implements IScaffolderAction {

for (const file of files) {
await app.destination.delete(file)
app.dispatch(new FileDeletedEvent(app.templates.resolve(file)))
app.dispatch(new FileDeletedEvent(app.destination.resolve(file)))
}
}
}
4 changes: 2 additions & 2 deletions packages/scaffold/src/actions/prepend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ export class PrependAction implements IScaffolderAction {
const skip = skipIf ? skipIf.test(source) : false

if (skip === true || idx === -1) {
app.dispatch(new FileSkippedEvent(app.templates.resolve(to)))
app.dispatch(new FileSkippedEvent(app.destination.resolve(to)))
return
}

lines.splice(idx, 0, rendered)

await app.destination.write(to, lines.join('\n'))

app.dispatch(new FileModifiedEvent(app.templates.resolve(to)))
app.dispatch(new FileModifiedEvent(app.destination.resolve(to)))
}
}
4 changes: 2 additions & 2 deletions packages/scaffold/src/actions/replace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ export class ReplaceAction implements IScaffolderAction {
const skip = skipIf ? skipIf.test(source) : false

if (skip === true || found === false) {
app.dispatch(new FileSkippedEvent(app.templates.resolve(to)))
app.dispatch(new FileSkippedEvent(app.destination.resolve(to)))
return
}

const transformed = source.replace(replace, rendered)

await app.destination.write(to, transformed)

app.dispatch(new FileModifiedEvent(app.templates.resolve(to)))
app.dispatch(new FileModifiedEvent(app.destination.resolve(to)))
}
}