mirror of
https://github.com/chenasraf/simple-scaffold.git
synced 2026-05-17 17:28:09 +00:00
fix: strip tmpDir from output dir (#108)
* fix: strip tmpDir from output dir * ci: test PRs * fix: cmd * fix: use relative path for replacement * chore: remove todo
This commit is contained in:
@@ -68,38 +68,34 @@ describe("config", () => {
|
||||
|
||||
describe("parseConfigFile", () => {
|
||||
test("normal config does not change", async () => {
|
||||
const tmpDir = `/tmp/scaffold-config-${Date.now()}`
|
||||
const { quiet, tmpDir: _tmpDir, version, ...conf } = blankCliConf
|
||||
expect(
|
||||
await parseConfigFile(
|
||||
{
|
||||
...blankCliConf,
|
||||
name: "-",
|
||||
},
|
||||
`/tmp/scaffold-config-${Date.now()}`,
|
||||
),
|
||||
).toEqual({ ...blankCliConf, name: "-" })
|
||||
await parseConfigFile({
|
||||
...blankCliConf,
|
||||
name: "-",
|
||||
tmpDir,
|
||||
}),
|
||||
).toEqual({ ...conf, name: "-", tmpDir, subdirHelper: undefined, beforeWrite: undefined })
|
||||
})
|
||||
describe("appendData", () => {
|
||||
test("appends", async () => {
|
||||
const result = await parseConfigFile(
|
||||
{
|
||||
...blankCliConf,
|
||||
name: "-",
|
||||
appendData: { key: "value" },
|
||||
},
|
||||
`/tmp/scaffold-config-${Date.now()}`,
|
||||
)
|
||||
const result = await parseConfigFile({
|
||||
...blankCliConf,
|
||||
name: "-",
|
||||
appendData: { key: "value" },
|
||||
tmpDir: `/tmp/scaffold-config-${Date.now()}`,
|
||||
})
|
||||
expect(result?.data?.key).toEqual("value")
|
||||
})
|
||||
test("overwrites existing value", async () => {
|
||||
const result = await parseConfigFile(
|
||||
{
|
||||
...blankCliConf,
|
||||
name: "-",
|
||||
data: { num: "123" },
|
||||
appendData: { num: "1234" },
|
||||
},
|
||||
`/tmp/scaffold-config-${Date.now()}`,
|
||||
)
|
||||
const result = await parseConfigFile({
|
||||
...blankCliConf,
|
||||
name: "-",
|
||||
data: { num: "123" },
|
||||
appendData: { num: "1234" },
|
||||
tmpDir: `/tmp/scaffold-config-${Date.now()}`,
|
||||
})
|
||||
expect(result?.data?.num).toEqual("1234")
|
||||
})
|
||||
})
|
||||
@@ -110,7 +106,7 @@ describe("config", () => {
|
||||
const resultFn = await config.getRemoteConfig({
|
||||
git: "https://github.com/chenasraf/simple-scaffold.git",
|
||||
logLevel: LogLevel.none,
|
||||
tmpPath: `/tmp/scaffold-config-${Date.now()}`,
|
||||
tmpDir: `/tmp/scaffold-config-${Date.now()}`,
|
||||
})
|
||||
const result = await resolve(resultFn, blankCliConf)
|
||||
expect(result).toEqual(blankCliConf)
|
||||
|
||||
@@ -23,7 +23,7 @@ describe("parser", () => {
|
||||
Object.defineProperty(path, "sep", { value: origSep })
|
||||
})
|
||||
test("should work for windows paths", async () => {
|
||||
expect(handlebarsParse(blankConf, "C:\\exports\\{{name}}.txt", { isPath: true }).toString()).toEqual(
|
||||
expect(handlebarsParse(blankConf, "C:\\exports\\{{name}}.txt", { asPath: true }).toString()).toEqual(
|
||||
"C:\\exports\\test.txt",
|
||||
)
|
||||
})
|
||||
@@ -37,7 +37,7 @@ describe("parser", () => {
|
||||
Object.defineProperty(path, "sep", { value: origSep })
|
||||
})
|
||||
test("should work for non-windows paths", async () => {
|
||||
expect(handlebarsParse(blankConf, "/home/test/{{name}}.txt", { isPath: true })).toEqual(
|
||||
expect(handlebarsParse(blankConf, "/home/test/{{name}}.txt", { asPath: true })).toEqual(
|
||||
Buffer.from("/home/test/test.txt"),
|
||||
)
|
||||
})
|
||||
@@ -48,7 +48,7 @@ describe("parser", () => {
|
||||
{ ...blankConf, data: { ...blankConf.data, escaped: "value" } },
|
||||
"/home/test/{{name}} \\{{escaped}}.txt",
|
||||
{
|
||||
isPath: false,
|
||||
asPath: false,
|
||||
},
|
||||
),
|
||||
).toEqual(Buffer.from("/home/test/test {{escaped}}.txt"))
|
||||
|
||||
Reference in New Issue
Block a user