Skip to content
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

Preserve @copyright comments as part of "some" default #1153

Merged
merged 2 commits into from Feb 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions README.md
Expand Up @@ -127,8 +127,8 @@ a double dash to prevent input files being used as option arguments:
as JSON to STDOUT respectively.
--comments [filter] Preserve copyright comments in the output. By
default this works like Google Closure, keeping
JSDoc-style comments that contain "@license" or
"@preserve". You can optionally pass one of the
JSDoc-style comments that contain e.g. "@license",
or start with "!". You can optionally pass one of the
following arguments to this flag:
- "all" to keep all comments
- `false` to omit comments in the output
Expand Down Expand Up @@ -989,8 +989,8 @@ as "output options".
statement.

- `comments` (default `"some"`) -- by default it keeps JSDoc-style comments
that contain "@license", "@preserve" or start with `!`, pass `true` or
`"all"` to preserve all comments, `false` to omit comments in the output,
that contain "@license", "@copyright", "@preserve" or start with `!`, pass `true`
or `"all"` to preserve all comments, `false` to omit comments in the output,
a regular expression string (e.g. `/^!/`) or a function.

- `ecma` (default `5`) -- set desired EcmaScript standard version for output.
Expand Down Expand Up @@ -1062,9 +1062,9 @@ as "output options".
### Keeping copyright notices or other comments

You can pass `--comments` to retain certain comments in the output. By
default it will keep JSDoc-style comments that contain "@preserve",
"@license" or "@cc_on" (conditional compilation for IE). You can pass
`--comments all` to keep all the comments, or a valid JavaScript regexp to
default it will keep comments starting with "!" and JSDoc-style comments that
contain "@preserve", "@copyright", "@license" or "@cc_on" (conditional compilation for IE).
You can pass `--comments all` to keep all the comments, or a valid JavaScript regexp to
keep only comments that match this regexp. For example `--comments /^!/`
will keep comments like `/*! Copyright Notice */`.

Expand Down
2 changes: 1 addition & 1 deletion lib/output.js
Expand Up @@ -172,7 +172,7 @@ function is_some_comments(comment) {
// multiline comment
return (
(comment.type === "comment2" || comment.type === "comment1")
&& /@preserve|@lic|@cc_on|^\**!/i.test(comment.value)
&& /@preserve|@copyright|@lic|@cc_on|^\**!/i.test(comment.value)
);
}

Expand Down
2 changes: 2 additions & 0 deletions test/compress/comments.js
Expand Up @@ -29,13 +29,15 @@ preserve_comments_by_default: {
/**! foo */
/*! foo */
/* lost */
/* @copyright …info… */
}
expect_exact: [
"var foo={};",
"/* @license */",
"// @lic",
"/**! foo */",
"/*! foo */",
"/* @copyright …info… */",
]
}

Expand Down