diff --git a/package.json b/package.json index 0140f13..fc40fd0 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "description": "A lightweight library to give some additions for the [rss-parser package](https://github.com/rbren/rss-parser).", "main": "index.js", "scripts": { - "test": "mocha --require ts-node/register ./tests/**/*-spec.ts" + "test": "mocha --require ts-node/register ./tests/**/*-spec.ts", + "build": "tsc -p ./src" }, "repository": { "type": "git", diff --git a/src/Models/ListenerRSSInfos.ts b/src/Models/ListenerRSSInfos.ts index f1098ca..c5d2eb2 100644 --- a/src/Models/ListenerRSSInfos.ts +++ b/src/Models/ListenerRSSInfos.ts @@ -1,4 +1,4 @@ -class ListenerRSSInfos { +export default class ListenerRSSInfos { _name: string = ""; // name of the listener _address: string = ""; // feed's address _timeloop: number | undefined = 5 * 60; // update time RSS feed @@ -42,5 +42,3 @@ class ListenerRSSInfos { return this._customfields; } } - -module.exports = ListenerRSSInfos; diff --git a/src/index.ts b/src/index.ts index 25c4a2a..b5e7995 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -import ListenerRss from "./listener-rss.ts"; +import ListenerRss from "./listener-rss"; import ListenerRSSInfo from "./Models/ListenerRSSInfos"; // TODO J'ai des erreurs sur les imports, que je ne comprend pas trop diff --git a/src/listener-rss.ts b/src/listener-rss.ts index af25966..f6cbe8d 100644 --- a/src/listener-rss.ts +++ b/src/listener-rss.ts @@ -1,11 +1,11 @@ import Parser from "rss-parser"; -import { ListenerRSSInfo as ListenerInfo } from "./Models/ListenerRSSInfos"; +import ListenerInfo from "./Models/ListenerRSSInfos"; const DEFAULT_TIMELOOP = 5 * 60; // default timeloop is 5 min -class ListenerRss { - name = undefined; - address = undefined; +export default class ListenerRss { + name = ""; + address = ""; timeloop = DEFAULT_TIMELOOP; // time in seconds customfields = []; @@ -93,5 +93,3 @@ class ListenerRss { this.loopRunning = false; } } - -module.exports = ListenerRss; diff --git a/src/tsconfig.json b/src/tsconfig.json new file mode 100644 index 0000000..9a2ee73 --- /dev/null +++ b/src/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../tsconfig.base.json", + "compilerOptions": { + "moduleResolution": "node" + }, + "exclude": [ + "build/", + "node_modules" + ] +} diff --git a/tests/tsconfig.json b/tests/tsconfig.json new file mode 100644 index 0000000..035f11b --- /dev/null +++ b/tests/tsconfig.json @@ -0,0 +1,6 @@ +{ + "extends": "../tsconfig.base.json", + "compilerOptions": { + "module": "commonjs" + } +} diff --git a/tsconfig.json b/tsconfig.base.json similarity index 86% rename from tsconfig.json rename to tsconfig.base.json index 3b0d4c5..1021bc9 100644 --- a/tsconfig.json +++ b/tsconfig.base.json @@ -13,5 +13,9 @@ "resolveJsonModule": false, "skipLibCheck": true, "forceConsistentCasingInFileNames": true - } + }, + "exclude": [ + "build/", + "node_modules" + ] }