This commit is contained in:
parent
00d7c596e5
commit
e1cd5b5920
|
@ -1,15 +0,0 @@
|
||||||
module.exports = (require) => {
|
|
||||||
const path = require("path");
|
|
||||||
const killTheNewsletter = require(".").default;
|
|
||||||
const { webApplication, emailApplication } = killTheNewsletter(
|
|
||||||
path.join(__dirname, "data")
|
|
||||||
);
|
|
||||||
|
|
||||||
webApplication.listen(new URL(webApplication.get("url")).port, () => {
|
|
||||||
console.log(`Web server started at ${webApplication.get("url")}`);
|
|
||||||
});
|
|
||||||
|
|
||||||
emailApplication.listen(new URL(webApplication.get("email")).port, () => {
|
|
||||||
console.log(`Email server started at ${webApplication.get("email")}`);
|
|
||||||
});
|
|
||||||
};
|
|
|
@ -18,7 +18,7 @@
|
||||||
"bugs": "https://github.com/leafac/kill-the-newsletter/issues",
|
"bugs": "https://github.com/leafac/kill-the-newsletter/issues",
|
||||||
"homepage": "https://github.com/leafac/kill-the-newsletter#readme",
|
"homepage": "https://github.com/leafac/kill-the-newsletter#readme",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "ts-node-dev --poll src/index.ts configuration.development.js",
|
"start": "ts-node-dev --poll src/index.ts",
|
||||||
"test": "prettier --check \"src/**/*\" --end-of-line auto && jest",
|
"test": "prettier --check \"src/**/*\" --end-of-line auto && jest",
|
||||||
"prepare": "tsc"
|
"prepare": "tsc"
|
||||||
},
|
},
|
||||||
|
|
21
src/index.ts
21
src/index.ts
|
@ -520,9 +520,20 @@ export default function killTheNewsletter(
|
||||||
|
|
||||||
if (require.main === module) {
|
if (require.main === module) {
|
||||||
console.log(`Kill the Newsletter!/${VERSION}`);
|
console.log(`Kill the Newsletter!/${VERSION}`);
|
||||||
const configurationFile = path.resolve(
|
const configurationFile = process.argv[2];
|
||||||
process.argv[2] ?? path.join(process.cwd(), "configuration.js")
|
if (configurationFile === undefined) {
|
||||||
);
|
const { webApplication, emailApplication } = killTheNewsletter(
|
||||||
require(configurationFile)(require);
|
path.join(process.cwd(), "data")
|
||||||
console.log(`Configuration loaded from ‘${configurationFile}’.`);
|
);
|
||||||
|
webApplication.listen(new URL(webApplication.get("url")).port, () => {
|
||||||
|
console.log(`Web server started at ${webApplication.get("url")}`);
|
||||||
|
});
|
||||||
|
emailApplication.listen(new URL(webApplication.get("email")).port, () => {
|
||||||
|
console.log(`Email server started at ${webApplication.get("email")}`);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
const configurationFileAbsolute = path.resolve(configurationFile);
|
||||||
|
require(configurationFileAbsolute)(require);
|
||||||
|
console.log(`Configuration loaded from ‘${configurationFileAbsolute}’.`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue