Skip to content
This repository has been archived by the owner on Jun 15, 2024. It is now read-only.

Commit

Permalink
refactor ConcatMultiple (typescript), remove generateBrokerWatch
Browse files Browse the repository at this point in the history
  • Loading branch information
matus-sabo committed Jan 9, 2020
1 parent 28cf83a commit b2ffbfd
Show file tree
Hide file tree
Showing 35 changed files with 4,896 additions and 2,673 deletions.
3,835 changes: 2,105 additions & 1,730 deletions examples/empty-broker/package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions examples/empty-broker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "tsc",
"dev:watch": "ts-node src/dev.watch.ts",
"dev:watch": "ts-node src/bin/dev.watch.ts",
"dev:broker:gen": "ts-node src/bin/dev.broker.gen.ts",
"postinstall": "ts-patch install"
},
"author": "",
"license": "ISC",
"dependencies": {
"moleculer": "^0.13.11",
"moleculer-decorators": "^1.1.1",
"moleculer-ts": "^1.0.5"
"moleculer-ts": "file:../.."
},
"devDependencies": {
"prettier": "^1.18.2",
Expand Down
43 changes: 43 additions & 0 deletions examples/empty-broker/src/bin/dev.broker.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { generateBroker } from 'moleculer-ts';
import watch from 'glob-watcher';

const brokers = ['empty-broker'];

export function isWatchMode() {
return process.argv.length >= 2 && process.argv[2] === '--watch';
}

brokers.forEach(async broker => {
let brokerRootDir = `${process.cwd()}/src/${broker}`;
const generateBrokerOptions = {
serviceTypesPattern: `${brokerRootDir}/**/*.service.types.ts`,
outputDir: `${brokerRootDir}/types`,
};

if (isWatchMode()) {
const watcher = watch(
generateBrokerOptions.serviceTypesPattern,
async done => {
try {
await generateBroker(generateBrokerOptions);
} catch (err) {
console.error(err);
} finally {
done();
}
},
);
watcher.on('change', filename => {
console.log(`Generate broker ${broker}, file changed: `, filename);
});
}
console.log(`Generate broker ${broker}`);
await generateBroker(generateBrokerOptions);
});

process.on('unhandledRejection', (reason, promise) => {
console.error('Unhandled Rejection at:', promise, 'reason:', reason);
if (!isWatchMode()) {
process.exit(1);
}
});
1 change: 1 addition & 0 deletions examples/empty-broker/src/bin/dev.watch.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
require('./dev.broker.gen');
16 changes: 0 additions & 16 deletions examples/empty-broker/src/dev.watch.ts

This file was deleted.

Loading

0 comments on commit b2ffbfd

Please sign in to comment.