Compare commits

..

5 Commits

Author SHA1 Message Date
0a302bee95 1.0.22 2019-10-12 16:54:19 +02:00
deb5e1daf9 1.0.21 2019-10-12 16:54:03 +02:00
5fe27ee706 fix(core): update 2019-10-12 16:54:03 +02:00
b73807baf0 1.0.20 2019-10-12 15:57:44 +02:00
1e71fc24d5 fix(core): update 2019-10-12 15:57:43 +02:00
5 changed files with 2685 additions and 54 deletions

2667
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{ {
"name": "@gitzone/tswatch", "name": "@gitzone/tswatch",
"version": "1.0.19", "version": "1.0.22",
"private": false, "private": false,
"description": "watch typescript projects during development", "description": "watch typescript projects during development",
"main": "dist/index.js", "main": "dist/index.js",
@@ -12,8 +12,7 @@
}, },
"scripts": { "scripts": {
"test": "(tstest test/)", "test": "(tstest test/)",
"build": "(tsbuild)", "build": "(tsbuild)"
"format": "(gitzone format)"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.17", "@gitzone/tsbuild": "^2.1.17",
@@ -24,6 +23,7 @@
"tslint-config-prettier": "^1.18.0" "tslint-config-prettier": "^1.18.0"
}, },
"dependencies": { "dependencies": {
"@gitzone/tsbundle": "^1.0.47",
"@gitzone/tsrun": "^1.2.8", "@gitzone/tsrun": "^1.2.8",
"@pushrocks/early": "^3.0.3", "@pushrocks/early": "^3.0.3",
"@pushrocks/lik": "^3.0.11", "@pushrocks/lik": "^3.0.11",
@@ -32,7 +32,9 @@
"@pushrocks/smartdelay": "^2.0.3", "@pushrocks/smartdelay": "^2.0.3",
"@pushrocks/smartlog": "^2.0.19", "@pushrocks/smartlog": "^2.0.19",
"@pushrocks/smartlog-destination-local": "^8.0.2", "@pushrocks/smartlog-destination-local": "^8.0.2",
"@pushrocks/smartshell": "^2.0.25" "@pushrocks/smartserve": "^1.1.37",
"@pushrocks/smartshell": "^2.0.25",
"@pushrocks/taskbuffer": "^2.0.15"
}, },
"files": [ "files": [
"ts/**/*", "ts/**/*",

View File

@@ -38,8 +38,13 @@ export class TsWatch {
case 'gitzone_element': case 'gitzone_element':
this.watcherMap.add( this.watcherMap.add(
new Watcher({ new Watcher({
filePathToWatch: plugins.path.join(paths.cwd, 'ts_web'), filePathToWatch: plugins.path.join(paths.cwd, './ts_web/'),
commandToExecute: 'npm run build', commandToExecute: async () => {
const tsbundle = new plugins.tsbundle.TsBundle();
const htmlHandler = new plugins.tsbundle.HtmlHandler();
await tsbundle.buildProduction('./ts_web', 'dist_web');
await htmlHandler.copyHtml();
},
timeout: null timeout: null
}) })
); );

View File

@@ -1,9 +1,11 @@
import * as plugins from './tswatch.plugins'; import * as plugins from './tswatch.plugins';
import { logger } from './tswatch.logging'; import { logger } from './tswatch.logging';
export type TCommandFunction = () => Promise<void>;
export interface IWatcherConstructorOptions { export interface IWatcherConstructorOptions {
filePathToWatch: string; filePathToWatch: string;
commandToExecute: string; commandToExecute: string | TCommandFunction;
timeout?: number; timeout?: number;
} }
@@ -11,9 +13,28 @@ export interface IWatcherConstructorOptions {
* A watcher keeps track of one child execution * A watcher keeps track of one child execution
*/ */
export class Watcher { export class Watcher {
/**
* used to execute shell commands
*/
private smartshellInstance = new plugins.smartshell.Smartshell({ private smartshellInstance = new plugins.smartshell.Smartshell({
executor: 'bash' executor: 'bash'
}); });
/**
* used to execute
*/
private executionTask: plugins.taskbuffer.Task = new plugins.taskbuffer.Task({
name: 'watcherCommandFunctionTask',
taskFunction: async () => {
if (typeof this.options.commandToExecute === 'string') {
throw new Error('cannot execute string as task');
}
await this.options.commandToExecute();
},
buffered: true,
bufferMax: 1
});
private currentExecution: plugins.smartshell.IExecResultStreaming; private currentExecution: plugins.smartshell.IExecResultStreaming;
private smartchokWatcher = new plugins.smartchok.Smartchok([], {}); private smartchokWatcher = new plugins.smartchok.Smartchok([], {});
private options: IWatcherConstructorOptions; private options: IWatcherConstructorOptions;
@@ -41,6 +62,7 @@ export class Watcher {
* updates the current execution * updates the current execution
*/ */
private async updateCurrentExecution() { private async updateCurrentExecution() {
if (typeof this.options.commandToExecute === 'string') {
if (this.currentExecution) { if (this.currentExecution) {
logger.log('ok', `reexecuting ${this.options.commandToExecute}`); logger.log('ok', `reexecuting ${this.options.commandToExecute}`);
process.kill(-this.currentExecution.childProcess.pid); process.kill(-this.currentExecution.childProcess.pid);
@@ -51,6 +73,9 @@ export class Watcher {
this.options.commandToExecute this.options.commandToExecute
); );
this.currentExecution = null; this.currentExecution = null;
} else {
await this.executionTask.trigger();
}
} }
/** /**

View File

@@ -1,6 +1,13 @@
import * as path from 'path'; import * as path from 'path';
export { path }; export { path };
// @gitzone scope
import * as tsbundle from '@gitzone/tsbundle';
export {
tsbundle
};
// @pushrocks scope // @pushrocks scope
import * as lik from '@pushrocks/lik'; import * as lik from '@pushrocks/lik';
import * as smartchok from '@pushrocks/smartchok'; import * as smartchok from '@pushrocks/smartchok';
@@ -9,5 +16,6 @@ import * as smartdelay from '@pushrocks/smartdelay';
import * as smartlog from '@pushrocks/smartlog'; import * as smartlog from '@pushrocks/smartlog';
import * as smartlogDestinationLocal from '@pushrocks/smartlog-destination-local'; import * as smartlogDestinationLocal from '@pushrocks/smartlog-destination-local';
import * as smartshell from '@pushrocks/smartshell'; import * as smartshell from '@pushrocks/smartshell';
import * as taskbuffer from '@pushrocks/taskbuffer';
export { lik, smartchok, smartcli, smartdelay, smartlog, smartlogDestinationLocal, smartshell }; export { lik, smartchok, smartcli, smartdelay, smartlog, smartlogDestinationLocal, smartshell, taskbuffer };