Skip to content

Commit

Permalink
Do not convert to string the files by processing them
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanBluefox committed Dec 6, 2024
1 parent 1c34969 commit bb08f6f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,10 @@ node node_modules/@iobroker/build-tools/convertI18n.js path/to/i18n
-->

## Changelog
### **WORK IN PROGRESS**

- (@GermanBluefox) Do not convert to string the files by processing them

### 2.0.9 (2024-11-25)

- (@GermanBluefox) Treat exit code 1 as error
Expand Down
7 changes: 4 additions & 3 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export function copyFiles(
patterns: string[] | string,
dest: string,
options?: {
process?: (fileData: string, fileName: string) => string | null | undefined | false;
process?: (fileData: Buffer | string, fileName: string) => string | null | undefined | false;
replace?: { find: string | RegExp; text: string }[];
},
): void {
Expand All @@ -157,10 +157,11 @@ export function copyFiles(
}
console.log(`[${new Date().toISOString()}] Copy "${files[f].base}/${files[f].name}" to "${destName}"`);
if (options) {
let data = readFileSync(files[f].base ? `${files[f].base}/${files[f].name}` : files[f].name).toString(
'utf8',
let data: Buffer | string = readFileSync(
files[f].base ? `${files[f].base}/${files[f].name}` : files[f].name,
);
if (options.replace) {
data = data.toString('utf8');
for (let r = 0; r < options.replace.length; r++) {
data = data.replace(options.replace[r].find, options.replace[r].text);
}
Expand Down

0 comments on commit bb08f6f

Please sign in to comment.