Skip to content

Commit df58aca

Browse files
authored
Merge pull request #40 from TomerAberbach/master
Add support for .mjs and .cjs JavaScript file extensions
2 parents 68a83ed + 3fa0684 commit df58aca

File tree

5 files changed

+57
-1
lines changed

5 files changed

+57
-1
lines changed

main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ func licenseHeader(path string, tmpl *template.Template, data *copyrightData) ([
207207
return nil, nil
208208
case ".c", ".h":
209209
lic, err = prefix(tmpl, data, "/*", " * ", " */")
210-
case ".js", ".jsx", ".tsx", ".css", ".tf", ".ts":
210+
case ".js", ".mjs", ".cjs", ".jsx", ".tsx", ".css", ".tf", ".ts":
211211
lic, err = prefix(tmpl, data, "/**", " * ", " */")
212212
case ".cc", ".cpp", ".cs", ".go", ".hh", ".hpp", ".java", ".m", ".mm", ".proto", ".rs", ".scala", ".swift", ".dart", ".groovy", ".kt", ".kts":
213213
lic, err = prefix(tmpl, data, "", "// ", "")

testdata/expected/file.cjs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Copyright 2018 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
function dummy() {
18+
console.log('hello world!');
19+
}
20+
21+
module.exports = dummy
22+

testdata/expected/file.mjs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Copyright 2018 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
function dummy() {
18+
console.log('hello world!');
19+
}
20+
21+
export default dummy
22+

testdata/initial/file.cjs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
function dummy() {
2+
console.log('hello world!');
3+
}
4+
5+
module.exports = dummy
6+

testdata/initial/file.mjs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
function dummy() {
2+
console.log('hello world!');
3+
}
4+
5+
export default dummy
6+

0 commit comments

Comments
 (0)