-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
Add 'bundle' subcommand. #2467
Merged
Merged
Add 'bundle' subcommand. #2467
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
11926e6
Add 'bundle' subcommand.
kitsonk 4cdc261
Fix clippy issues.
kitsonk eb2cc00
Add tests, address feedback.
kitsonk 6dfc2a8
Remove sources from inline source map.
kitsonk 70b7451
Fix compiler tests.
kitsonk 6a4b7d2
fmt
ry fcd5eae
cleanup
ry 67994ec
Merge branch 'master' into bundler
ry File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -154,6 +154,16 @@ To get help on the another subcommands (run in this case): | |
Includes versions of Deno, V8 JavaScript Engine, and the TypeScript | ||
compiler.", | ||
), | ||
).subcommand( | ||
SubCommand::with_name("bundle") | ||
.setting(AppSettings::DisableVersion) | ||
.about("Bundle module and dependnecies into single file") | ||
.long_about( | ||
"Fetch, compile, and output to a single file a module and its dependencies. | ||
" | ||
) | ||
.arg(Arg::with_name("source_file").takes_value(true).required(true)) | ||
.arg(Arg::with_name("out_file").takes_value(true).required(true)), | ||
).subcommand( | ||
SubCommand::with_name("fetch") | ||
.setting(AppSettings::DisableVersion) | ||
|
@@ -436,6 +446,7 @@ const PRETTIER_URL: &str = "https://deno.land/[email protected]/prettier/main.ts"; | |
/// There is no "Help" subcommand because it's handled by `clap::App` itself. | ||
#[derive(Debug, PartialEq)] | ||
pub enum DenoSubcommand { | ||
Bundle, | ||
Eval, | ||
Fetch, | ||
Info, | ||
|
@@ -455,6 +466,13 @@ pub fn flags_from_vec( | |
let mut flags = parse_flags(&matches.clone()); | ||
|
||
let subcommand = match matches.subcommand() { | ||
("bundle", Some(bundle_match)) => { | ||
flags.allow_write = true; | ||
let source_file: &str = bundle_match.value_of("source_file").unwrap(); | ||
let out_file: &str = bundle_match.value_of("out_file").unwrap(); | ||
argv.extend(vec![source_file.to_string(), out_file.to_string()]); | ||
DenoSubcommand::Bundle | ||
} | ||
("eval", Some(eval_match)) => { | ||
flags.allow_net = true; | ||
flags.allow_env = true; | ||
|
@@ -1034,4 +1052,19 @@ mod tests { | |
assert_eq!(subcommand, DenoSubcommand::Run); | ||
assert_eq!(argv, svec!["deno", "script.ts"]); | ||
} | ||
|
||
#[test] | ||
fn test_flags_from_vec_26() { | ||
let (flags, subcommand, argv) = | ||
flags_from_vec(svec!["deno", "bundle", "source.ts", "bundle.js"]); | ||
assert_eq!( | ||
flags, | ||
DenoFlags { | ||
allow_write: true, | ||
..DenoFlags::default() | ||
} | ||
); | ||
assert_eq!(subcommand, DenoSubcommand::Bundle); | ||
assert_eq!(argv, svec!["deno", "source.ts", "bundle.js"]) | ||
} | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can you give an example command here that can be copied and pasted, so people can try it out quickly?
Maybe use a remote URL, like