fix(publish): changedPostDirs gibt pfade mit original-contentRoot zurück
This commit is contained in:
parent
6055a8c1cc
commit
ccbfc61a7c
|
|
@ -53,8 +53,13 @@ export interface DiffArgs {
|
||||||
export async function changedPostDirs(args: DiffArgs): Promise<string[]> {
|
export async function changedPostDirs(args: DiffArgs): Promise<string[]> {
|
||||||
const runner = args.runner ?? defaultRunner
|
const runner = args.runner ?? defaultRunner
|
||||||
const stdout = await runner(['diff', '--name-only', `${args.from}..${args.to}`])
|
const stdout = await runner(['diff', '--name-only', `${args.from}..${args.to}`])
|
||||||
const normalizedRoot = stripParentSegments(args.contentRoot)
|
const normalizedRoot = stripParentSegments(args.contentRoot).replace(/\/$/, '')
|
||||||
return filterPostDirs(stdout.split('\n'), normalizedRoot)
|
const originalRoot = args.contentRoot.replace(/\/$/, '')
|
||||||
|
if (normalizedRoot === originalRoot) {
|
||||||
|
return filterPostDirs(stdout.split('\n'), originalRoot)
|
||||||
|
}
|
||||||
|
const matched = filterPostDirs(stdout.split('\n'), normalizedRoot)
|
||||||
|
return matched.map((p) => originalRoot + p.slice(normalizedRoot.length))
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function allPostDirs(contentRoot: string): Promise<string[]> {
|
export async function allPostDirs(contentRoot: string): Promise<string[]> {
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ Deno.test('changedPostDirs: normalisiert contentRoot mit ../-präfix', async ()
|
||||||
contentRoot: '../content/posts',
|
contentRoot: '../content/posts',
|
||||||
runner,
|
runner,
|
||||||
})
|
})
|
||||||
assertEquals(dirs.sort(), ['content/posts/de/alpha', 'content/posts/en/beta'])
|
assertEquals(dirs.sort(), ['../content/posts/de/alpha', '../content/posts/en/beta'])
|
||||||
})
|
})
|
||||||
|
|
||||||
Deno.test('changedPostDirs: normalisiert contentRoot mit mehrfachem ../-präfix', async () => {
|
Deno.test('changedPostDirs: normalisiert contentRoot mit mehrfachem ../-präfix', async () => {
|
||||||
|
|
@ -106,7 +106,19 @@ Deno.test('changedPostDirs: normalisiert contentRoot mit mehrfachem ../-präfix'
|
||||||
contentRoot: '../../content/posts',
|
contentRoot: '../../content/posts',
|
||||||
runner,
|
runner,
|
||||||
})
|
})
|
||||||
assertEquals(dirs, ['content/posts/de/alpha'])
|
assertEquals(dirs, ['../../content/posts/de/alpha'])
|
||||||
|
})
|
||||||
|
|
||||||
|
Deno.test('changedPostDirs: gibt pfade mit original-contentRoot zurück (CWD-relativ)', async () => {
|
||||||
|
const runner: GitRunner = () =>
|
||||||
|
Promise.resolve('content/posts/de/alpha/index.md\n')
|
||||||
|
const dirs = await changedPostDirs({
|
||||||
|
from: 'HEAD~1',
|
||||||
|
to: 'HEAD',
|
||||||
|
contentRoot: '../content/posts',
|
||||||
|
runner,
|
||||||
|
})
|
||||||
|
assertEquals(dirs, ['../content/posts/de/alpha'])
|
||||||
})
|
})
|
||||||
|
|
||||||
Deno.test('allPostDirs: findet posts in sprach-unterordnern', async () => {
|
Deno.test('allPostDirs: findet posts in sprach-unterordnern', async () => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue