-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: use cli-tools * feat: use cli-tools * feat: support for deprecated config file name * fix: auto import
- Loading branch information
1 parent
9601980
commit 073e7c5
Showing
6 changed files
with
54 additions
and
232 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,16 @@ | ||
import {existsSync} from 'node:fs'; | ||
import {access} from 'node:fs/promises'; | ||
import {join} from 'node:path'; | ||
import {JUNO_DEV_CONFIG_FILENAME, JUNO_DEV_JSON} from '../constants/constants'; | ||
import type {ConfigFilename} from '@junobuild/cli-tools'; | ||
import { | ||
junoConfigExist as junoConfigExistTools, | ||
junoConfigFile as junoConfigFileTools | ||
} from '@junobuild/cli-tools'; | ||
import {JUNO_DEV_CONFIG_FILENAME} from '../constants/constants'; | ||
import type {ConfigType} from '../types/config'; | ||
|
||
const JUNO_DEV_CONFIG_FILE: {filename: ConfigFilename} = {filename: JUNO_DEV_CONFIG_FILENAME}; | ||
|
||
export const junoDevConfigExist = async (): Promise<boolean> => { | ||
try { | ||
const {configPath} = junoDevConfigFile(); | ||
await access(configPath); | ||
return true; | ||
} catch (err: unknown) { | ||
if (err instanceof Error && 'code' in err && (err as NodeJS.ErrnoException).code === 'ENOENT') { | ||
return false; | ||
} else { | ||
throw err; | ||
} | ||
} | ||
return await junoConfigExistTools(JUNO_DEV_CONFIG_FILE); | ||
}; | ||
|
||
export const junoDevConfigFile = (): {configPath: string; configType: ConfigType} => { | ||
const junoTs = join(process.cwd(), `${JUNO_DEV_CONFIG_FILENAME}.ts`); | ||
|
||
if (existsSync(junoTs)) { | ||
return { | ||
configPath: junoTs, | ||
configType: 'ts' | ||
}; | ||
} | ||
|
||
const junoJs = join(process.cwd(), `${JUNO_DEV_CONFIG_FILENAME}.js`); | ||
|
||
if (existsSync(junoJs)) { | ||
return { | ||
configPath: junoJs, | ||
configType: 'js' | ||
}; | ||
} | ||
|
||
const junoMjs = join(process.cwd(), `${JUNO_DEV_CONFIG_FILENAME}.mjs`); | ||
|
||
if (existsSync(junoMjs)) { | ||
return { | ||
configPath: junoMjs, | ||
configType: 'js' | ||
}; | ||
} | ||
|
||
const junoCjs = join(process.cwd(), `${JUNO_DEV_CONFIG_FILENAME}.cjs`); | ||
|
||
if (existsSync(junoCjs)) { | ||
return { | ||
configPath: junoCjs, | ||
configType: 'js' | ||
}; | ||
} | ||
|
||
// Support for original juno.json file | ||
const junoJsonDeprecated = join(process.cwd(), JUNO_DEV_JSON); | ||
|
||
if (existsSync(junoJsonDeprecated)) { | ||
return { | ||
configPath: junoJsonDeprecated, | ||
configType: 'json' | ||
}; | ||
} | ||
|
||
return { | ||
configPath: join(process.cwd(), `${JUNO_DEV_CONFIG_FILENAME}.json`), | ||
configType: 'json' | ||
}; | ||
}; | ||
export const junoDevConfigFile = (): {configPath: string; configType: ConfigType} => | ||
junoConfigFileTools(JUNO_DEV_CONFIG_FILE); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.