2022-03-14 21:04:11 +00:00
|
|
|
import * as plugins from './tswatch.plugins.js';
|
|
|
|
import * as paths from './tswatch.paths.js';
|
|
|
|
import './interfaces/index.js';
|
|
|
|
import { Watcher } from './tswatch.classes.watcher.js';
|
|
|
|
export class TsWatch {
|
2020-05-22 07:25:34 +00:00
|
|
|
constructor(watchmodeArg) {
|
|
|
|
this.watcherMap = new plugins.lik.ObjectMap();
|
|
|
|
this.watchmode = watchmodeArg;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* starts the TsWatch instance
|
|
|
|
*/
|
|
|
|
async start() {
|
|
|
|
switch (this.watchmode) {
|
|
|
|
case 'test':
|
2022-03-14 21:04:11 +00:00
|
|
|
this.watcherMap.add(new Watcher({
|
2020-05-22 07:25:34 +00:00
|
|
|
filePathToWatch: paths.cwd,
|
|
|
|
commandToExecute: 'npm run test2',
|
2021-03-08 00:26:44 +00:00
|
|
|
timeout: null,
|
2020-05-22 07:25:34 +00:00
|
|
|
}));
|
|
|
|
break;
|
|
|
|
case 'gitzone_npm':
|
2022-03-14 21:04:11 +00:00
|
|
|
this.watcherMap.add(new Watcher({
|
2020-05-22 07:25:34 +00:00
|
|
|
filePathToWatch: paths.cwd,
|
|
|
|
commandToExecute: 'npm run test',
|
2021-03-08 00:26:44 +00:00
|
|
|
timeout: null,
|
2020-05-22 07:25:34 +00:00
|
|
|
}));
|
|
|
|
break;
|
|
|
|
case 'gitzone_element':
|
|
|
|
// lets create a standard server
|
|
|
|
console.log('bundling TypeScript files to "dist_watch" Note: This is for development only!');
|
2021-03-08 00:26:44 +00:00
|
|
|
const parcel = new plugins.smartparcel.Parcel(plugins.path.join(process.cwd(), './html/index.html'), plugins.path.join(process.cwd(), './dist_watch'), 'index.html');
|
2022-03-14 21:04:11 +00:00
|
|
|
await parcel.watchAndServe();
|
2020-05-22 07:25:34 +00:00
|
|
|
break;
|
|
|
|
case 'gitzone_website':
|
2022-03-14 21:04:11 +00:00
|
|
|
this.watcherMap.add(new Watcher({
|
2020-05-22 07:25:34 +00:00
|
|
|
filePathToWatch: plugins.path.join(paths.cwd, './ts/'),
|
|
|
|
commandToExecute: 'npm run startTs',
|
2021-03-08 00:26:44 +00:00
|
|
|
timeout: null,
|
2020-05-22 07:25:34 +00:00
|
|
|
}));
|
|
|
|
// client directory
|
2022-03-14 21:04:11 +00:00
|
|
|
const parcelWebsite = new plugins.smartparcel.Parcel(plugins.path.join(process.cwd(), './html/index.html'), plugins.path.join(process.cwd(), './dist_serve'), 'bundle.js');
|
|
|
|
await parcelWebsite.watchAndServe();
|
2020-05-22 07:25:34 +00:00
|
|
|
break;
|
|
|
|
case 'gitzone_service':
|
2022-03-14 21:04:11 +00:00
|
|
|
this.watcherMap.add(new Watcher({
|
2020-05-22 07:25:34 +00:00
|
|
|
filePathToWatch: plugins.path.join(paths.cwd, './ts/'),
|
|
|
|
commandToExecute: 'npm run startTs',
|
2021-03-08 00:26:44 +00:00
|
|
|
timeout: null,
|
2020-05-22 07:25:34 +00:00
|
|
|
}));
|
|
|
|
break;
|
|
|
|
case 'echoSomething':
|
2022-03-14 21:04:11 +00:00
|
|
|
const tsWatchInstanceEchoSomething = new Watcher({
|
2020-05-22 07:25:34 +00:00
|
|
|
filePathToWatch: plugins.path.join(paths.cwd, './ts'),
|
|
|
|
commandToExecute: 'npm -v',
|
2021-03-08 00:26:44 +00:00
|
|
|
timeout: null,
|
2020-05-22 07:25:34 +00:00
|
|
|
});
|
|
|
|
this.watcherMap.add(tsWatchInstanceEchoSomething);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
this.watcherMap.forEach(async (watcher) => {
|
|
|
|
await watcher.start();
|
|
|
|
});
|
|
|
|
if (this.smartserve) {
|
|
|
|
await this.smartserve.start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* stops the execution of any active Watchers
|
|
|
|
*/
|
|
|
|
async stop() {
|
|
|
|
if (this.smartserve) {
|
|
|
|
await this.smartserve.stop();
|
|
|
|
}
|
|
|
|
this.watcherMap.forEach(async (watcher) => {
|
|
|
|
await watcher.stop();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2022-03-14 21:04:11 +00:00
|
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHN3YXRjaC5jbGFzc2VzLnRzd2F0Y2guanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy90c3dhdGNoLmNsYXNzZXMudHN3YXRjaC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssT0FBTyxNQUFNLHNCQUFzQixDQUFDO0FBQ2hELE9BQU8sS0FBSyxLQUFLLE1BQU0sb0JBQW9CLENBQUM7QUFDNUMsT0FBNEIsdUJBQXVCLENBQUM7QUFFcEQsT0FBTyxFQUFFLE9BQU8sRUFBRSxNQUFNLDhCQUE4QixDQUFDO0FBRXZELE1BQU0sT0FBTyxPQUFPO0lBS2xCLFlBQVksWUFBb0M7UUFIekMsZUFBVSxHQUFHLElBQUksT0FBTyxDQUFDLEdBQUcsQ0FBQyxTQUFTLEVBQVcsQ0FBQztRQUl2RCxJQUFJLENBQUMsU0FBUyxHQUFHLFlBQVksQ0FBQztJQUNoQyxDQUFDO0lBRUQ7O09BRUc7SUFDSSxLQUFLLENBQUMsS0FBSztRQUNoQixRQUFRLElBQUksQ0FBQyxTQUFTLEVBQUU7WUFDdEIsS0FBSyxNQUFNO2dCQUNULElBQUksQ0FBQyxVQUFVLENBQUMsR0FBRyxDQUNqQixJQUFJLE9BQU8sQ0FBQztvQkFDVixlQUFlLEVBQUUsS0FBSyxDQUFDLEdBQUc7b0JBQzFCLGdCQUFnQixFQUFFLGVBQWU7b0JBQ2pDLE9BQU8sRUFBRSxJQUFJO2lCQUNkLENBQUMsQ0FDSCxDQUFDO2dCQUNGLE1BQU07WUFDUixLQUFLLGFBQWE7Z0JBQ2hCLElBQUksQ0FBQyxVQU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