Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
3b9f180d
Unverified
Commit
3b9f180d
authored
Jun 13, 2022
by
JJ Kasper
Committed by
GitHub
Jun 13, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow passing FileRef directly to createNext (#37664)
* Allow passing FileRef directly to createNext * update type
parent
b62bb97b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
17 deletions
+36
-17
e2e-utils.ts
test/lib/e2e-utils.ts
+5
-3
base.ts
test/lib/next-modes/base.ts
+31
-14
No files found.
test/lib/e2e-utils.ts
View file @
3b9f180d
...
...
@@ -111,9 +111,11 @@ if (typeof afterAll === 'function') {
* to prevent relying on modules that shouldn't be
*/
export
async
function
createNext
(
opts
:
{
files
:
{
[
filename
:
string
]:
string
|
FileRef
}
files
:
|
FileRef
|
{
[
filename
:
string
]:
string
|
FileRef
}
dependencies
?:
{
[
name
:
string
]:
string
}
...
...
test/lib/next-modes/base.ts
View file @
3b9f180d
...
...
@@ -16,9 +16,11 @@ export type PackageJson = {
[
key
:
string
]:
unknown
}
export
class
NextInstance
{
protected
files
:
{
[
filename
:
string
]:
string
|
FileRef
}
protected
files
:
|
FileRef
|
{
[
filename
:
string
]:
string
|
FileRef
}
protected
nextConfig
?:
NextConfig
protected
installCommand
?:
InstallCommand
protected
buildCommand
?:
string
...
...
@@ -47,9 +49,11 @@ export class NextInstance {
packageLockPath
,
env
,
}:
{
files
:
{
[
filename
:
string
]:
string
|
FileRef
}
files
:
|
FileRef
|
{
[
filename
:
string
]:
string
|
FileRef
}
dependencies
?:
{
[
name
:
string
]:
string
}
...
...
@@ -148,15 +152,28 @@ export class NextInstance {
require
(
'console'
).
log
(
'created next.js install, writing test files'
)
}
for
(
const
filename
of
Object
.
keys
(
this
.
files
))
{
const
item
=
this
.
files
[
filename
]
const
outputfilename
=
path
.
join
(
this
.
testDir
,
filename
)
if
(
this
.
files
instanceof
FileRef
)
{
// if a FileRef is passed directly to `files` we copy the
// entire folder to the test directory
const
stats
=
await
fs
.
stat
(
this
.
files
.
fsPath
)
if
(
!
stats
.
isDirectory
())
{
throw
new
Error
(
`FileRef passed to "files" in "createNext" is not a directory
${
this
.
files
.
fsPath
}
`
)
}
await
fs
.
copy
(
this
.
files
.
fsPath
,
this
.
testDir
)
}
else
{
for
(
const
filename
of
Object
.
keys
(
this
.
files
))
{
const
item
=
this
.
files
[
filename
]
const
outputFilename
=
path
.
join
(
this
.
testDir
,
filename
)
if
(
typeof
item
===
'string'
)
{
await
fs
.
ensureDir
(
path
.
dirname
(
outputfilename
))
await
fs
.
writeFile
(
outputfilename
,
item
)
}
else
{
await
fs
.
copy
(
item
.
fsPath
,
outputfilename
)
if
(
typeof
item
===
'string'
)
{
await
fs
.
ensureDir
(
path
.
dirname
(
outputFilename
))
await
fs
.
writeFile
(
outputFilename
,
item
)
}
else
{
await
fs
.
copy
(
item
.
fsPath
,
outputFilename
)
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment