Skip to content

Commit

Permalink
fix: ensure copying hbs templates
Browse files Browse the repository at this point in the history
  • Loading branch information
psanders committed Dec 1, 2023
1 parent 8f996cd commit 572bbcb
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 0 deletions.
49 changes: 49 additions & 0 deletions .scripts/copy-hbs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
* http://github.com/fonoster/goodtok
*
* This file is part of Goodtok
*
* Licensed under the MIT License (the "License");
* you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* https://opensource.org/licenses/MIT
*
* 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.
*/
const fs = require('fs-extra');
const path = require('path');

const sourceDir = './src/notifications';
const destDir = './dist/notifications';

function copyHbsFiles(source, destination) {
fs.readdir(source, { withFileTypes: true }, (err, files) => {
if (err) {
console.error('error reading source directory:', err);
return;
}

files.forEach(file => {
const sourcePath = path.join(source, file.name);
const destPath = path.join(destination, file.name);

if (file.isDirectory()) {
copyHbsFiles(sourcePath, destPath);
} else if (file.isFile() && sourcePath.endsWith('.hbs')) {
fs.copy(sourcePath, destPath, err => {
if (err) {
console.error('error copying file:', sourcePath, err);
}
});
}
});
});
}

copyHbsFiles(sourceDir, destDir);
1 change: 1 addition & 0 deletions compose.dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ services:
build:
context: .
dockerfile: ./mods/apiserver/Dockerfile

nats:
image: nats:latest
ports:
Expand Down
2 changes: 2 additions & 0 deletions mods/apiserver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"scripts": {
"prebuild": "rimraf ./dist tsconfig.tsbuildinfo",
"build": "tsc -b tsconfig.json",
"postbuild": "node ../../.scripts/copy-hbs.js",
"clean": "rimraf ./dist node_modules tsconfig.tsbuildinfo"
},
"bin": {
Expand Down Expand Up @@ -71,6 +72,7 @@
"@types/jsonwebtoken": "^9.0.3",
"@types/nodemailer": "^6.4.14",
"@types/ws": "^8.5.6",
"fs-extra": "^11.2.0",
"prisma": "^5.4.1"
}
}
15 changes: 15 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 572bbcb

Please sign in to comment.