Skip to content

extend thinks of files without extension as folders #267

@devbro1

Description

@devbro1

Environment

export default {
  extends: ['./databases'],
}

// databases.ts
export default {
    db1: true,
}

the following code will fail to load databases.ts because extension is not provided. JITI is able to load ts files without extensions but when used within context of extends, it is not used to load the file.

further more tryResolve will assume anything without extension is a folder.

Reproduction

// index.ts
import { loadConfig } from 'c12';

const { config: config_data } = await loadConfig({
  cwd: dirname(fileURLToPath(import.meta.url)) + '/config',
  configFile: './default',
  extend: { extendKey: 'extends' },
});
// config/detaulf.ts
export default {
  //extends: './databases', // cannot find 
  extends: './databases.ts', // works fine
};
// config/databases.ts
export default {
    databases: {
    host: process.env.DB_HOST,
    database: process.env.DB_NAME || 'test_db',
    user: process.env.DB_USER,
    password: process.env.DB_PASSWORD,
    port: parseInt(process.env.DB_PORT || '5432'),
    name: 'db',
    },
    $test: {
    databases: {
      meow: 124,
    }
  },
};

Describe the bug

when using extends, if a file is given without extension it is treated as folder.

Additional context

No response

Logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions