chore: generate
This commit is contained in:
@@ -25,7 +25,9 @@ async function resolveRelativeInstruction(instruction: string): Promise<string[]
|
|||||||
return Filesystem.globUp(instruction, Instance.directory, Instance.worktree).catch(() => [])
|
return Filesystem.globUp(instruction, Instance.directory, Instance.worktree).catch(() => [])
|
||||||
}
|
}
|
||||||
if (!Flag.OPENCODE_CONFIG_DIR) {
|
if (!Flag.OPENCODE_CONFIG_DIR) {
|
||||||
log.warn(`Skipping relative instruction "${instruction}" - no OPENCODE_CONFIG_DIR set while project config is disabled`)
|
log.warn(
|
||||||
|
`Skipping relative instruction "${instruction}" - no OPENCODE_CONFIG_DIR set while project config is disabled`,
|
||||||
|
)
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
return Filesystem.globUp(instruction, Flag.OPENCODE_CONFIG_DIR, Flag.OPENCODE_CONFIG_DIR).catch(() => [])
|
return Filesystem.globUp(instruction, Flag.OPENCODE_CONFIG_DIR, Flag.OPENCODE_CONFIG_DIR).catch(() => [])
|
||||||
|
|||||||
@@ -1417,7 +1417,7 @@ describe("OPENCODE_DISABLE_PROJECT_CONFIG", () => {
|
|||||||
test("skips project config files when flag is set", async () => {
|
test("skips project config files when flag is set", async () => {
|
||||||
const originalEnv = process.env["OPENCODE_DISABLE_PROJECT_CONFIG"]
|
const originalEnv = process.env["OPENCODE_DISABLE_PROJECT_CONFIG"]
|
||||||
process.env["OPENCODE_DISABLE_PROJECT_CONFIG"] = "true"
|
process.env["OPENCODE_DISABLE_PROJECT_CONFIG"] = "true"
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await using tmp = await tmpdir({
|
await using tmp = await tmpdir({
|
||||||
init: async (dir) => {
|
init: async (dir) => {
|
||||||
@@ -1453,17 +1453,14 @@ describe("OPENCODE_DISABLE_PROJECT_CONFIG", () => {
|
|||||||
test("skips project .opencode/ directories when flag is set", async () => {
|
test("skips project .opencode/ directories when flag is set", async () => {
|
||||||
const originalEnv = process.env["OPENCODE_DISABLE_PROJECT_CONFIG"]
|
const originalEnv = process.env["OPENCODE_DISABLE_PROJECT_CONFIG"]
|
||||||
process.env["OPENCODE_DISABLE_PROJECT_CONFIG"] = "true"
|
process.env["OPENCODE_DISABLE_PROJECT_CONFIG"] = "true"
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await using tmp = await tmpdir({
|
await using tmp = await tmpdir({
|
||||||
init: async (dir) => {
|
init: async (dir) => {
|
||||||
// Create a .opencode directory with a command
|
// Create a .opencode directory with a command
|
||||||
const opencodeDir = path.join(dir, ".opencode", "command")
|
const opencodeDir = path.join(dir, ".opencode", "command")
|
||||||
await fs.mkdir(opencodeDir, { recursive: true })
|
await fs.mkdir(opencodeDir, { recursive: true })
|
||||||
await Bun.write(
|
await Bun.write(path.join(opencodeDir, "test-cmd.md"), "# Test Command\nThis is a test command.")
|
||||||
path.join(opencodeDir, "test-cmd.md"),
|
|
||||||
"# Test Command\nThis is a test command.",
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
await Instance.provide({
|
await Instance.provide({
|
||||||
@@ -1471,7 +1468,7 @@ describe("OPENCODE_DISABLE_PROJECT_CONFIG", () => {
|
|||||||
fn: async () => {
|
fn: async () => {
|
||||||
const directories = await Config.directories()
|
const directories = await Config.directories()
|
||||||
// Project .opencode should NOT be in directories list
|
// Project .opencode should NOT be in directories list
|
||||||
const hasProjectOpencode = directories.some(d => d.startsWith(tmp.path))
|
const hasProjectOpencode = directories.some((d) => d.startsWith(tmp.path))
|
||||||
expect(hasProjectOpencode).toBe(false)
|
expect(hasProjectOpencode).toBe(false)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -1487,7 +1484,7 @@ describe("OPENCODE_DISABLE_PROJECT_CONFIG", () => {
|
|||||||
test("still loads global config when flag is set", async () => {
|
test("still loads global config when flag is set", async () => {
|
||||||
const originalEnv = process.env["OPENCODE_DISABLE_PROJECT_CONFIG"]
|
const originalEnv = process.env["OPENCODE_DISABLE_PROJECT_CONFIG"]
|
||||||
process.env["OPENCODE_DISABLE_PROJECT_CONFIG"] = "true"
|
process.env["OPENCODE_DISABLE_PROJECT_CONFIG"] = "true"
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await using tmp = await tmpdir()
|
await using tmp = await tmpdir()
|
||||||
await Instance.provide({
|
await Instance.provide({
|
||||||
@@ -1511,12 +1508,12 @@ describe("OPENCODE_DISABLE_PROJECT_CONFIG", () => {
|
|||||||
test("skips relative instructions with warning when flag is set but no config dir", async () => {
|
test("skips relative instructions with warning when flag is set but no config dir", async () => {
|
||||||
const originalDisable = process.env["OPENCODE_DISABLE_PROJECT_CONFIG"]
|
const originalDisable = process.env["OPENCODE_DISABLE_PROJECT_CONFIG"]
|
||||||
const originalConfigDir = process.env["OPENCODE_CONFIG_DIR"]
|
const originalConfigDir = process.env["OPENCODE_CONFIG_DIR"]
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Ensure no config dir is set
|
// Ensure no config dir is set
|
||||||
delete process.env["OPENCODE_CONFIG_DIR"]
|
delete process.env["OPENCODE_CONFIG_DIR"]
|
||||||
process.env["OPENCODE_DISABLE_PROJECT_CONFIG"] = "true"
|
process.env["OPENCODE_DISABLE_PROJECT_CONFIG"] = "true"
|
||||||
|
|
||||||
await using tmp = await tmpdir({
|
await using tmp = await tmpdir({
|
||||||
init: async (dir) => {
|
init: async (dir) => {
|
||||||
// Create a config with relative instruction path
|
// Create a config with relative instruction path
|
||||||
@@ -1531,7 +1528,7 @@ describe("OPENCODE_DISABLE_PROJECT_CONFIG", () => {
|
|||||||
await Bun.write(path.join(dir, "CUSTOM.md"), "# Custom Instructions")
|
await Bun.write(path.join(dir, "CUSTOM.md"), "# Custom Instructions")
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
await Instance.provide({
|
await Instance.provide({
|
||||||
directory: tmp.path,
|
directory: tmp.path,
|
||||||
fn: async () => {
|
fn: async () => {
|
||||||
@@ -1561,7 +1558,7 @@ describe("OPENCODE_DISABLE_PROJECT_CONFIG", () => {
|
|||||||
test("OPENCODE_CONFIG_DIR still works when flag is set", async () => {
|
test("OPENCODE_CONFIG_DIR still works when flag is set", async () => {
|
||||||
const originalDisable = process.env["OPENCODE_DISABLE_PROJECT_CONFIG"]
|
const originalDisable = process.env["OPENCODE_DISABLE_PROJECT_CONFIG"]
|
||||||
const originalConfigDir = process.env["OPENCODE_CONFIG_DIR"]
|
const originalConfigDir = process.env["OPENCODE_CONFIG_DIR"]
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await using configDirTmp = await tmpdir({
|
await using configDirTmp = await tmpdir({
|
||||||
init: async (dir) => {
|
init: async (dir) => {
|
||||||
@@ -1575,7 +1572,7 @@ describe("OPENCODE_DISABLE_PROJECT_CONFIG", () => {
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
await using projectTmp = await tmpdir({
|
await using projectTmp = await tmpdir({
|
||||||
init: async (dir) => {
|
init: async (dir) => {
|
||||||
// Create config in project (should be ignored)
|
// Create config in project (should be ignored)
|
||||||
@@ -1588,10 +1585,10 @@ describe("OPENCODE_DISABLE_PROJECT_CONFIG", () => {
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
process.env["OPENCODE_DISABLE_PROJECT_CONFIG"] = "true"
|
process.env["OPENCODE_DISABLE_PROJECT_CONFIG"] = "true"
|
||||||
process.env["OPENCODE_CONFIG_DIR"] = configDirTmp.path
|
process.env["OPENCODE_CONFIG_DIR"] = configDirTmp.path
|
||||||
|
|
||||||
await Instance.provide({
|
await Instance.provide({
|
||||||
directory: projectTmp.path,
|
directory: projectTmp.path,
|
||||||
fn: async () => {
|
fn: async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user