-
Notifications
You must be signed in to change notification settings - Fork 366
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(nodebox): support env vars on commands (#755)
- Loading branch information
Showing
4 changed files
with
87 additions
and
11 deletions.
There are no files selected for viewing
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,61 @@ | ||
import { findStartScriptPackageJson } from "./client.utils"; | ||
|
||
describe(findStartScriptPackageJson, () => { | ||
it("should parse a regular command", () => { | ||
expect( | ||
findStartScriptPackageJson(JSON.stringify({ scripts: { start: "node" } })) | ||
).toEqual(["node", [], { env: undefined }]); | ||
}); | ||
|
||
it("should parse a regular command with arguments", () => { | ||
expect( | ||
findStartScriptPackageJson( | ||
JSON.stringify({ scripts: { start: "node dev --foo" } }) | ||
) | ||
).toEqual(["node", ["dev", "--foo"], { env: undefined }]); | ||
}); | ||
|
||
it("should get dev script first", () => { | ||
expect( | ||
findStartScriptPackageJson( | ||
JSON.stringify({ | ||
scripts: { start: "node start --foo", dev: "node dev --foo" }, | ||
}) | ||
) | ||
).toEqual(["node", ["dev", "--foo"], { env: undefined }]); | ||
}); | ||
|
||
it("should parse env vars", () => { | ||
expect( | ||
findStartScriptPackageJson( | ||
JSON.stringify({ | ||
scripts: { start: "NODE=1 ANOTHER=2 node start --foo" }, | ||
}) | ||
) | ||
).toEqual([ | ||
"node", | ||
["start", "--foo"], | ||
{ env: { NODE: "1", ANOTHER: "2" } }, | ||
]); | ||
}); | ||
|
||
it("should parse a single env var", () => { | ||
expect( | ||
findStartScriptPackageJson( | ||
JSON.stringify({ | ||
scripts: { start: "NODE=1 node start --foo" }, | ||
}) | ||
) | ||
).toEqual(["node", ["start", "--foo"], { env: { NODE: "1" } }]); | ||
}); | ||
|
||
it("should parse a single env var and a single commmand", () => { | ||
expect( | ||
findStartScriptPackageJson( | ||
JSON.stringify({ | ||
scripts: { start: "NODE=1 node" }, | ||
}) | ||
) | ||
).toEqual(["node", [], { env: { NODE: "1" } }]); | ||
}); | ||
}); |
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
af8d5c1
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.
Successfully deployed to the following URLs:
sandpack-docs – ./website/docs
sandpack-docs-codesandbox1.vercel.app
sandpack-docs-git-main-codesandbox1.vercel.app
sandpack.vercel.app