mirror of
https://github.com/Xaymar/obs-StreamFX
synced 2024-12-28 02:21:25 +00:00
tools: Only check for the section start/end signal, not the entire line
This commit is contained in:
parent
d1e3b6d0d1
commit
75e13996f1
1 changed files with 27 additions and 18 deletions
|
@ -1,6 +1,6 @@
|
|||
/* AUTOGENERATED COPYRIGHT HEADER START
|
||||
* Copyright (C) 2023 Michael Fabian 'Xaymar' Dirks <info@xaymar.com>
|
||||
* AUTOGENERATED COPYRIGHT HEADER END */
|
||||
// AUTOGENERATED COPYRIGHT HEADER START
|
||||
// Copyright (C) 2023 Michael Fabian 'Xaymar' Dirks <info@xaymar.com>
|
||||
// AUTOGENERATED COPYRIGHT HEADER END
|
||||
const CHILD_PROCESS = require("node:child_process");
|
||||
const PROCESS = require("node:process");
|
||||
const PATH = require("node:path");
|
||||
|
@ -8,6 +8,9 @@ const FS = require("node:fs");
|
|||
const FSPROMISES = require("node:fs/promises");
|
||||
const OS = require("os");
|
||||
|
||||
const SECTION_START = "AUTOGENERATED COPYRIGHT HEADER START";
|
||||
const SECTION_END = "AUTOGENERATED COPYRIGHT HEADER END";
|
||||
|
||||
async function git_isIgnored(path) {
|
||||
await new Promise((resolve, reject) => {
|
||||
try {
|
||||
|
@ -148,10 +151,10 @@ function makeHeader(file, copyright) {
|
|||
".yml",
|
||||
],
|
||||
prepend: [
|
||||
"#\u0020AUTOGENERATED COPYRIGHT HEADER START",
|
||||
`# ${SECTION_START}`,
|
||||
],
|
||||
append: [
|
||||
"#\u0020AUTOGENERATED COPYRIGHT HEADER END",
|
||||
`# ${SECTION_END}`,
|
||||
],
|
||||
prefix: "# ",
|
||||
suffix: "",
|
||||
|
@ -164,15 +167,15 @@ function makeHeader(file, copyright) {
|
|||
".iss.in",
|
||||
],
|
||||
prepend: [
|
||||
";\u0020AUTOGENERATED COPYRIGHT HEADER START",
|
||||
`; ${SECTION_START}`,
|
||||
],
|
||||
append: [
|
||||
";\u0020AUTOGENERATED COPYRIGHT HEADER END",
|
||||
`; ${SECTION_END}`,
|
||||
],
|
||||
prefix: "; ",
|
||||
suffix: "",
|
||||
},
|
||||
"/**/": {
|
||||
"//": {
|
||||
files: [
|
||||
], exts: [
|
||||
".c",
|
||||
|
@ -189,12 +192,12 @@ function makeHeader(file, copyright) {
|
|||
".effect"
|
||||
],
|
||||
prepend: [
|
||||
"/*\u0020AUTOGENERATED COPYRIGHT HEADER START",
|
||||
`// ${SECTION_START}`,
|
||||
],
|
||||
append: [
|
||||
" *\u0020AUTOGENERATED COPYRIGHT HEADER END */",
|
||||
`// ${SECTION_END}`,
|
||||
],
|
||||
prefix: " * ",
|
||||
prefix: "// ",
|
||||
suffix: "",
|
||||
},
|
||||
"<!---->": {
|
||||
|
@ -212,13 +215,13 @@ function makeHeader(file, copyright) {
|
|||
".pkgproj.in",
|
||||
],
|
||||
prepend: [
|
||||
"<!--\u0020AUTOGENERATED COPYRIGHT HEADER START",
|
||||
`<!-- ${SECTION_START} -->`,
|
||||
],
|
||||
append: [
|
||||
" --\u0020AUTOGENERATED COPYRIGHT HEADER END -->",
|
||||
`<!-- ${SECTION_END} -->`,
|
||||
],
|
||||
prefix: " --",
|
||||
suffix: "",
|
||||
prefix: "<!-- ",
|
||||
suffix: " -->",
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -251,9 +254,15 @@ async function addCopyright(file) {
|
|||
let header = makeHeader(file, copyright);
|
||||
let insert = Buffer.from(header.join(eol) + eol);
|
||||
|
||||
let startHeader = content.indexOf(header[0]);
|
||||
let endHeader = content.indexOf(header[header.length - 1], startHeader + 1);
|
||||
endHeader += header[header.length - 1].length + eol.length;
|
||||
// Find the starting point.
|
||||
let startHeader = content.indexOf(SECTION_START);
|
||||
startHeader = content.lastIndexOf(eol, startHeader);
|
||||
startHeader += Buffer.from(eol).byteLength;
|
||||
|
||||
// Find the ending point.
|
||||
let endHeader = content.indexOf(SECTION_END);
|
||||
endHeader = content.indexOf(eol, endHeader);
|
||||
endHeader += Buffer.from(eol).byteLength;
|
||||
|
||||
let fd = await FSPROMISES.open(file, "w+");
|
||||
let fp = [];
|
||||
|
|
Loading…
Reference in a new issue