Skip to content

Commit

Permalink
refactor: remove unusued watchModules command
Browse files Browse the repository at this point in the history
  • Loading branch information
edvald committed Apr 25, 2018
1 parent 76fabd6 commit 920eacc
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 38 deletions.
1 change: 0 additions & 1 deletion src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

import chalk from "chalk"
import { PluginContext } from "../plugin-context"
import { BooleanParameter, Command, ParameterValues, StringParameter } from "./base"
import { BuildTask } from "../tasks/build"
Expand Down
4 changes: 2 additions & 2 deletions src/commands/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ function getGreetingTime() {

const currentHour = parseFloat(m.format("HH"))

if ( currentHour >= 17 ) {
if (currentHour >= 17) {
return "evening"
} else if ( currentHour >= 12 ) {
} else if (currentHour >= 12) {
return "afternoon"
} else {
return "morning"
Expand Down
4 changes: 0 additions & 4 deletions src/types/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ export interface ModuleConfig<T extends ServiceConfig = ServiceConfig> {
variables: PrimitiveMap
}

interface ModuleConstructor<T extends ModuleConfig = ModuleConfig> {
new (ctx: PluginContext, config: T): Module<T>
}

export class Module<T extends ModuleConfig = ModuleConfig> {
public name: string
public type: string
Expand Down
1 change: 0 additions & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import * as Cryo from "cryo"
import { spawn as _spawn } from "child_process"
import { existsSync, readFileSync, writeFileSync } from "fs"
import { join } from "path"
import { getLogger } from "./logger"
import {
TimeoutError,
GardenError,
Expand Down
31 changes: 1 addition & 30 deletions src/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,6 @@ export interface OnChangeHandler {
(ctx: PluginContext, module: Module): Promise<void>
}

export async function watchModules(
ctx: PluginContext, modules: Module[], onChange: OnChangeHandler,
): Promise<FSWatcher> {
const autoReloadDependants = await computeAutoReloadDependants(modules)

async function handleChanges(module: Module) {
await onChange(ctx, module)

const dependantsForModule = autoReloadDependants[module.name]
if (!dependantsForModule) {
return
}

for (const dependant of dependantsForModule) {
await handleChanges(dependant)
}
}

const watcher = new FSWatcher(ctx.projectRoot)
await watcher.watchModules(modules, "addTasksForAutoReload/",
async (changedModule) => {
ctx.log.debug({ msg: `Files changed for module ${changedModule.name}` })
await handleChanges(changedModule)
await ctx.processTasks()
})

return watcher
}

export async function computeAutoReloadDependants(modules: Module[]):
Promise<AutoReloadDependants> {
let dependants = {}
Expand Down Expand Up @@ -127,7 +98,7 @@ export class FSWatcher {
const relModulePath = relative(result.watch, modulePath)

const subscriptionRequest = {
expression: ["dirname", relModulePath, ["depth", "ge", 0]]
expression: ["dirname", relModulePath, ["depth", "ge", 0]],
}

await this.command([
Expand Down

0 comments on commit 920eacc

Please sign in to comment.