@promise-watch/core
Advanced tools
Comparing version 1.1.0-next.3 to 1.1.0-next.4
@@ -1,2 +0,2 @@ | ||
import { ExecuteOptions } from "./types"; | ||
export declare function executeJobs(options: ExecuteOptions): Promise<void>; | ||
import { ExecuteOptions, PromiseWatchOptions } from "./types"; | ||
export declare function executeJobs(options: PromiseWatchOptions | ExecuteOptions): Promise<void>; |
@@ -8,4 +8,4 @@ "use strict"; | ||
async function executeJobs(options) { | ||
const { dir, notifiers = [], globPath = "runs/**/*.{js,ts}" } = options; | ||
let runs = await (0, import_runs_1.importRunsFromPath)(globPath, dir); | ||
const { notifiers = [], globPath = "runs/**/*.{js,ts}" } = options; | ||
let runs = await (0, import_runs_1.importRunsFromPath)(globPath); | ||
runs = (0, filter_runs_1.filterRunsWithoutRequiredFields)(runs); | ||
@@ -12,0 +12,0 @@ await Promise.allSettled(runs.map(run => (0, recursively_run_1.recursivelyRun)(run, notifiers))); |
import { RunPage } from "./types"; | ||
export declare function importRunsFromPath(globPath: string, dir: string): Promise<RunPage[]>; | ||
export declare function importRunsFromPath(globPath: string): Promise<RunPage[]>; |
@@ -29,5 +29,5 @@ "use strict"; | ||
const path_1 = require("path"); | ||
async function importRunsFromPath(globPath, dir) { | ||
async function importRunsFromPath(globPath) { | ||
const files = await (0, glob_promise_1.glob)(globPath); | ||
const promises = files.map(f => (0, path_1.resolve)(dir, f)); | ||
const promises = files.map(f => (0, path_1.resolve)(process.cwd(), f)); | ||
const imports = await Promise.all(promises.map(f => Promise.resolve().then(() => __importStar(require(f))))); | ||
@@ -34,0 +34,0 @@ return imports.map((page, idx) => { |
@@ -1,7 +0,7 @@ | ||
export declare type RunPage = { | ||
export declare type RunPage<T = void> = { | ||
name: string; | ||
options: RunOptions; | ||
run(): Promise<void>; | ||
run(): Promise<T>; | ||
}; | ||
export declare type RunOptions = { | ||
export declare type RunPageOptions = { | ||
interval: number; | ||
@@ -12,7 +12,9 @@ notifiers?: Notifier[]; | ||
}; | ||
export declare type ExecuteOptions = { | ||
dir: string; | ||
export declare type RunOptions = RunPageOptions; | ||
export declare type PromiseWatchOptions = { | ||
globPath?: string; | ||
notifiers?: Notifier[]; | ||
notifiers: Notifier[]; | ||
dir?: string; | ||
}; | ||
export declare type ExecuteOptions = PromiseWatchOptions; | ||
export declare type SendOptions = { | ||
@@ -19,0 +21,0 @@ title: string; |
{ | ||
"name": "@promise-watch/core", | ||
"version": "1.1.0-next.3", | ||
"version": "1.1.0-next.4", | ||
"author": "Jason Raimondi <jason@raimondi.us> (https://jasonraimondi.com)", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
import { recursivelyRun } from "./recursively-run"; | ||
import { filterRunsWithoutRequiredFields } from "./filter-runs"; | ||
import { ExecuteOptions } from "./types"; | ||
import { ExecuteOptions, PromiseWatchOptions } from "./types"; | ||
import { importRunsFromPath } from "./import-runs"; | ||
export async function executeJobs(options: ExecuteOptions) { | ||
const { dir, notifiers = [], globPath = "runs/**/*.{js,ts}" } = options; | ||
let runs = await importRunsFromPath(globPath, dir); | ||
export async function executeJobs(options: PromiseWatchOptions | ExecuteOptions) { | ||
const { notifiers = [], globPath = "runs/**/*.{js,ts}" } = options; | ||
let runs = await importRunsFromPath(globPath); | ||
runs = filterRunsWithoutRequiredFields(runs); | ||
await Promise.allSettled(runs.map(run => recursivelyRun(run, notifiers))); | ||
} |
@@ -5,5 +5,5 @@ import { glob } from "./utils/glob-promise"; | ||
export async function importRunsFromPath(globPath: string, dir: string): Promise<RunPage[]> { | ||
export async function importRunsFromPath(globPath: string): Promise<RunPage[]> { | ||
const files = await glob(globPath); | ||
const promises = files.map(f => resolve(dir, f)); | ||
const promises = files.map(f => resolve(process.cwd(), f)); | ||
const imports = await Promise.all(promises.map(f => import(f))); | ||
@@ -10,0 +10,0 @@ return imports.map((page, idx) => ({ |
@@ -1,8 +0,8 @@ | ||
export type RunPage = { | ||
export type RunPage<T = void> = { | ||
name: string; | ||
options: RunOptions; | ||
run(): Promise<void>; | ||
run(): Promise<T>; | ||
}; | ||
export type RunOptions = { | ||
export type RunPageOptions = { | ||
interval: number; | ||
@@ -14,8 +14,23 @@ notifiers?: Notifier[]; | ||
export type ExecuteOptions = { | ||
dir: string; | ||
export type RunOptions = RunPageOptions; | ||
export type PromiseWatchOptions = { | ||
globPath?: string; | ||
notifiers?: Notifier[]; | ||
notifiers: Notifier[]; | ||
/** | ||
* @deprecated | ||
* This field is no longer used, T | ||
* @todo remove in v2.x | ||
*/ | ||
dir?: string; | ||
}; | ||
/** | ||
* @deprecated | ||
* Use PromiseWatchOptions instead, this will be removed in v2.x | ||
* @todo remove in v2.x | ||
*/ | ||
export type ExecuteOptions = PromiseWatchOptions; | ||
export type SendOptions = { | ||
@@ -22,0 +37,0 @@ title: string; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
44047
687