-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolve config from extends package #781
Changes from all commits
358318d
53f6824
2cfa4f6
83010cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,17 @@ | ||
import { createRequire } from 'node:module'; | ||
import * as path from 'node:path'; | ||
import * as fs from 'node:fs'; | ||
import SilentError from 'silent-error'; | ||
import { GlintConfig } from './config.js'; | ||
import { GlintConfigInput } from '@glint/core/config-types'; | ||
import type * as TS from 'typescript'; | ||
|
||
const require = createRequire(import.meta.url); | ||
/** | ||
* @private | ||
* | ||
* Only exported for testing purposes. Do not import. | ||
*/ | ||
export const require = createRequire(import.meta.url); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why export this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah, it's for mocking in tests. can you add a block-comment with something like: /**
* @private
*
* Only exported for testing purposes. Do not import.
*/ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
|
||
type TypeScript = typeof TS; | ||
|
||
|
@@ -75,8 +81,19 @@ function loadConfigInput(ts: TypeScript, entryPath: string): GlintConfigInput | | |
); | ||
|
||
fullGlintConfig = { ...currentGlintConfig, ...fullGlintConfig }; | ||
currentPath = | ||
currentContents.extends && path.resolve(path.dirname(currentPath), currentContents.extends); | ||
|
||
if (currentContents.extends) { | ||
currentPath = path.resolve(path.dirname(currentPath), currentContents.extends); | ||
if (!fs.existsSync(currentPath)) { | ||
try { | ||
currentPath = require.resolve(currentContents.extends); | ||
} catch (error) { | ||
// control the exception, do nothing. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we log the error? What's the error thrown here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I log anything this test and others will fail Please refer to the image below that shows the error being displayed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ahh ok. thanks! |
||
} | ||
} | ||
} else { | ||
currentPath = undefined; | ||
} | ||
} | ||
|
||
return validateConfigInput(fullGlintConfig); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's local-env?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest, I simply followed the example from the previous test which uses a predefined environment in the beforeEach