Skip to content
代码片段 群组 项目
提交 deedd1a8 编辑于 作者: Timotej Ecimovic's avatar Timotej Ecimovic
浏览文件

Deal with test files and their requirement for that @jest-environment tag in the license adder.

上级 54cf5c30
No related branches found
No related tags found
无相关合并请求
...@@ -38,6 +38,27 @@ const licenseJs = `/** ...@@ -38,6 +38,27 @@ const licenseJs = `/**
*/ */
` `
const licenseTestJs = `/**
*
* Copyright (c) 2020 Silicon Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
* @jest-environment node
*/
`
const licenseXml = `<!-- const licenseXml = `<!--
Copyright (c) 2008,2020 Silicon Labs. Copyright (c) 2008,2020 Silicon Labs.
...@@ -61,12 +82,18 @@ const directories = ['src', 'src-electron', 'test'] ...@@ -61,12 +82,18 @@ const directories = ['src', 'src-electron', 'test']
async function processSingleFile(path) { async function processSingleFile(path) {
var isVue = path.endsWith('.vue') var isVue = path.endsWith('.vue')
var isJs = path.endsWith('.js') var isJs = path.endsWith('.js')
var isTestJs = path.endsWith('.test.js')
if (!(isVue || isJs)) return if (!(isVue || isJs)) return
fs.readFile(path, 'utf8', (err, data) => { fs.readFile(path, 'utf8', (err, data) => {
if (err) throw err if (err) throw err
if (isTestJs && data.startsWith(licenseTestJs)) {
console.log(` - valid: ${path}: `)
return
}
if (isJs && data.startsWith(licenseJs)) { if (isJs && data.startsWith(licenseJs)) {
console.log(` - valid: ${path}: `) console.log(` - valid: ${path}: `)
return return
...@@ -88,7 +115,7 @@ async function processSingleFile(path) { ...@@ -88,7 +115,7 @@ async function processSingleFile(path) {
} }
// Now we write license and then data // Now we write license and then data
var output = isJs ? licenseJs : licenseXml var output = isJs ? (isTestJs ? licenseTestJs : licenseJs) : licenseXml
output = output.concat(data) output = output.concat(data)
fs.writeFile(path, output, (err) => { fs.writeFile(path, output, (err) => {
if (err) throw err if (err) throw err
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册