-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Next 13 CSS File Location (#243)
- Loading branch information
Showing
11 changed files
with
484 additions
and
109 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import glob from 'glob'; | ||
import util from 'util'; | ||
|
||
export async function resolveCssLocation() { | ||
const [match] = await util.promisify(glob)('./**/globals.css'); | ||
|
||
if (!match) { | ||
return './styles/globals.css'; | ||
} | ||
|
||
return match; | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import glob from 'glob'; | ||
import { resolveCssLocation } from '../../src/frameworks/steps/next'; | ||
|
||
vi.mock('glob'); | ||
|
||
describe('Next JS CSS', () => { | ||
afterEach(() => { | ||
vi.clearAllMocks(); | ||
}); | ||
|
||
afterAll(() => { | ||
vi.resetAllMocks(); | ||
}); | ||
|
||
it('can resolve css location', async () => { | ||
vi.mocked(glob) | ||
.mockImplementationOnce((_, cb) => { | ||
console.log(typeof cb, cb); | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
return (cb as any)(null, ['foo']) as any; | ||
}) | ||
.mockImplementationOnce((_, cb) => { | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
return (cb as any)(null, []) as any; | ||
}); | ||
const first = await resolveCssLocation(); | ||
const second = await resolveCssLocation(); | ||
|
||
expect(first).toStrictEqual('foo'); | ||
expect(second).toStrictEqual('./styles/globals.css'); | ||
}); | ||
}); |