diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a56198..b28a2e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +#### 0.2.28 (2024-08-06) + +##### Bug Fixes + +* esm ([579f12da](https://github.com/zaaack/foy/commit/579f12dab5dcd34f0164c9512f247b8629a7a9c0)) + #### 0.2.27 (2024-08-05) ##### Bug Fixes diff --git a/docs/api/assets/highlight.css b/docs/api/assets/highlight.css index d032ff8..26dd909 100644 --- a/docs/api/assets/highlight.css +++ b/docs/api/assets/highlight.css @@ -9,30 +9,20 @@ --dark-hl-3: #569CD6; --light-hl-4: #008000; --dark-hl-4: #6A9955; - --light-hl-5: #008000; - --dark-hl-5: #569CD6; - --light-hl-6: #008000; - --dark-hl-6: #D4D4D4; - --light-hl-7: #008000; - --dark-hl-7: #4FC1FF; - --light-hl-8: #008000; - --dark-hl-8: #DCDCAA; - --light-hl-9: #008000; - --dark-hl-9: #CE9178; - --light-hl-10: #001080; - --dark-hl-10: #9CDCFE; - --light-hl-11: #AF00DB; - --dark-hl-11: #C586C0; - --light-hl-12: #000000FF; - --dark-hl-12: #D4D4D4; - --light-hl-13: #267F99; - --dark-hl-13: #4EC9B0; - --light-hl-14: #098658; - --dark-hl-14: #B5CEA8; - --light-hl-15: #0070C1; - --dark-hl-15: #4FC1FF; - --light-hl-16: #000000; - --dark-hl-16: #C8C8C8; + --light-hl-5: #0070C1; + --dark-hl-5: #4FC1FF; + --light-hl-6: #001080; + --dark-hl-6: #9CDCFE; + --light-hl-7: #AF00DB; + --dark-hl-7: #C586C0; + --light-hl-8: #000000FF; + --dark-hl-8: #D4D4D4; + --light-hl-9: #267F99; + --dark-hl-9: #4EC9B0; + --light-hl-10: #098658; + --dark-hl-10: #B5CEA8; + --light-hl-11: #000000; + --dark-hl-11: #C8C8C8; --light-code-background: #FFFFFF; --dark-code-background: #1E1E1E; } @@ -50,11 +40,6 @@ --hl-9: var(--light-hl-9); --hl-10: var(--light-hl-10); --hl-11: var(--light-hl-11); - --hl-12: var(--light-hl-12); - --hl-13: var(--light-hl-13); - --hl-14: var(--light-hl-14); - --hl-15: var(--light-hl-15); - --hl-16: var(--light-hl-16); --code-background: var(--light-code-background); } } @@ -71,11 +56,6 @@ --hl-9: var(--dark-hl-9); --hl-10: var(--dark-hl-10); --hl-11: var(--dark-hl-11); - --hl-12: var(--dark-hl-12); - --hl-13: var(--dark-hl-13); - --hl-14: var(--dark-hl-14); - --hl-15: var(--dark-hl-15); - --hl-16: var(--dark-hl-16); --code-background: var(--dark-code-background); } } @@ -92,11 +72,6 @@ --hl-9: var(--light-hl-9); --hl-10: var(--light-hl-10); --hl-11: var(--light-hl-11); - --hl-12: var(--light-hl-12); - --hl-13: var(--light-hl-13); - --hl-14: var(--light-hl-14); - --hl-15: var(--light-hl-15); - --hl-16: var(--light-hl-16); --code-background: var(--light-code-background); } @@ -113,11 +88,6 @@ --hl-9: var(--dark-hl-9); --hl-10: var(--dark-hl-10); --hl-11: var(--dark-hl-11); - --hl-12: var(--dark-hl-12); - --hl-13: var(--dark-hl-13); - --hl-14: var(--dark-hl-14); - --hl-15: var(--dark-hl-15); - --hl-16: var(--dark-hl-16); --code-background: var(--dark-code-background); } @@ -133,9 +103,4 @@ .hl-9 { color: var(--hl-9); } .hl-10 { color: var(--hl-10); } .hl-11 { color: var(--hl-11); } -.hl-12 { color: var(--hl-12); } -.hl-13 { color: var(--hl-13); } -.hl-14 { color: var(--hl-14); } -.hl-15 { color: var(--hl-15); } -.hl-16 { color: var(--hl-16); } pre, code { background: var(--code-background); } diff --git a/docs/api/classes/Logger.html b/docs/api/classes/Logger.html index eecf061..cb23535 100644 --- a/docs/api/classes/Logger.html +++ b/docs/api/classes/Logger.html @@ -1,8 +1,8 @@ -Logger | foy

Class Logger

Constructors

constructor +Logger | foy

Class Logger

Constructors

Properties

Accessors

Constructors

Properties

debug: ((...args: any[]) => void) = ...
error: ((...args: any[]) => void) = ...
info: ((...args: any[]) => void) = ...
log: ((...args: any[]) => void) = ...
warn: ((...args: any[]) => void) = ...

Accessors

+

Constructors

Properties

debug: ((...args: any[]) => void) = ...
error: ((...args: any[]) => void) = ...
info: ((...args: any[]) => void) = ...
log: ((...args: any[]) => void) = ...
warn: ((...args: any[]) => void) = ...

Accessors

diff --git a/docs/api/classes/ShellContext.html b/docs/api/classes/ShellContext.html index 5388a80..114d363 100644 --- a/docs/api/classes/ShellContext.html +++ b/docs/api/classes/ShellContext.html @@ -1,4 +1,4 @@ -ShellContext | foy

Class ShellContext

Constructors

constructor +ShellContext | foy

Class ShellContext

Constructors

Properties

_logger logCommand sleep @@ -12,21 +12,21 @@ pushd resetEnv spawn -

Constructors

Properties

_logger: Logger = logger
logCommand: boolean = false
sleep: ((ms: number) => Promise<void>) = sleep

Accessors

  • get cwd(): string
  • get current word directory

    -

    Returns string

Methods

  • set/get/delete env +

Constructors

Properties

_logger: Logger = logger
logCommand: boolean = false
sleep: ((ms: number) => Promise<void>) = sleep

Accessors

  • get cwd(): string
  • get current word directory

    +

    Returns string

Methods

  • set/get/delete env set: ctx.env('key', 'val') get: ctx.env('key') delete: ctx.env('key', void 0)

    -

    Parameters

    • key: string

    Returns undefined | string

  • Parameters

    • key: string
    • val: undefined | string

    Returns this

  • exec (multi-line) cmd in *unix platforms, +

    Parameters

    • key: string

    Returns undefined | string

  • Parameters

    • key: string
    • val: undefined | string

    Returns this

  • restart processes when file changes

    -

    Parameters

    • dir: string
    • run: string | string[] | ((p: {
          current: null | ChildProcess;
      }) => void)
    • options: WatchDirOptions & {
          ignore?: ((event: string, file: string) => boolean);
      } = {}

    Returns void

    ctx.monitor('./src', 'tsc')
    ctx.monitor('./src', 'webpack')
    ctx.monitor('./src', 'foy watch')
    ctx.monitor('./src', ['rm -rf dist', 'foy watch'])
    ctx.monitor('./src', async p => {
    await fs.rmrf('dist')
    p.current = ctx.exec('webpack serve')
    }) +

    Parameters

    • cmd: string
    • Optionaloptions: Options<string>

    Returns ExecaChildProcess<string>

  • restart processes when file changes

    +

    Parameters

    • dir: string
    • run: string | string[] | ((p: {
          current: null | ChildProcess;
      }) => void)
    • options: WatchDirOptions & {
          ignore?: ((event: string, file: string) => boolean);
      } = {}

    Returns void

    ctx.monitor('./src', 'tsc')
    ctx.monitor('./src', 'webpack')
    ctx.monitor('./src', 'foy watch')
    ctx.monitor('./src', ['rm -rf dist', 'foy watch'])
    ctx.monitor('./src', async p => {
    await fs.rmrf('dist')
    p.current = ctx.exec('webpack serve')
    })
    -
+
diff --git a/docs/api/functions/after.html b/docs/api/functions/after.html index 7cd426e..f68434f 100644 --- a/docs/api/functions/after.html +++ b/docs/api/functions/after.html @@ -1 +1 @@ -after | foy

Function after

  • Parameters

    • fn: ((t: Task<any>) => void | Promise<void>)
        • (t): void | Promise<void>
        • Parameters

          Returns void | Promise<void>

    Returns void

+after | foy

Function after

  • Parameters

    • fn: ((t: Task<any>) => void | Promise<void>)
        • (t): void | Promise<void>
        • Parameters

          Returns void | Promise<void>

    Returns void

diff --git a/docs/api/functions/before.html b/docs/api/functions/before.html index 1695d1c..f0f9453 100644 --- a/docs/api/functions/before.html +++ b/docs/api/functions/before.html @@ -1 +1 @@ -before | foy

Function before

  • Parameters

    • fn: ((t: Task<any>) => void | Promise<void>)
        • (t): void | Promise<void>
        • Parameters

          Returns void | Promise<void>

    Returns void

+before | foy

Function before

  • Parameters

    • fn: ((t: Task<any>) => void | Promise<void>)
        • (t): void | Promise<void>
        • Parameters

          Returns void | Promise<void>

    Returns void

diff --git a/docs/api/functions/defaults.html b/docs/api/functions/defaults.html index 1ade364..c2310eb 100644 --- a/docs/api/functions/defaults.html +++ b/docs/api/functions/defaults.html @@ -1 +1 @@ -defaults | foy

Function defaults

  • Type Parameters

    • T

    Parameters

    • val: undefined | T
    • defaultVal: T

    Returns T

  • Type Parameters

    • T

    Parameters

    • val: undefined | T
    • val1: undefined | T
    • defaultVal: T

    Returns T

  • Type Parameters

    • T

    Parameters

    • val: undefined | T
    • val1: undefined | T
    • val2: undefined | T
    • defaultVal: T

    Returns T

  • Type Parameters

    • T

    Parameters

    • val: undefined | T
    • val1: undefined | T
    • val2: undefined | T
    • val3: undefined | T
    • defaultVal: T

    Returns T

  • Type Parameters

    • T

    Parameters

    • val: undefined | T
    • val1: undefined | T
    • val2: undefined | T
    • val3: undefined | T
    • val4: undefined | T
    • defaultVal: T

    Returns T

+defaults | foy

Function defaults

  • Type Parameters

    • T

    Parameters

    • val: undefined | T
    • defaultVal: T

    Returns T

  • Type Parameters

    • T

    Parameters

    • val: undefined | T
    • val1: undefined | T
    • defaultVal: T

    Returns T

  • Type Parameters

    • T

    Parameters

    • val: undefined | T
    • val1: undefined | T
    • val2: undefined | T
    • defaultVal: T

    Returns T

  • Type Parameters

    • T

    Parameters

    • val: undefined | T
    • val1: undefined | T
    • val2: undefined | T
    • val3: undefined | T
    • defaultVal: T

    Returns T

  • Type Parameters

    • T

    Parameters

    • val: undefined | T
    • val1: undefined | T
    • val2: undefined | T
    • val3: undefined | T
    • val4: undefined | T
    • defaultVal: T

    Returns T

diff --git a/docs/api/functions/dep.html b/docs/api/functions/dep.html index 71954ff..8c6fd2a 100644 --- a/docs/api/functions/dep.html +++ b/docs/api/functions/dep.html @@ -1 +1 @@ -dep | foy

Function dep

+dep | foy

Function dep

diff --git a/docs/api/functions/desc.html b/docs/api/functions/desc.html index ef3921c..a91087e 100644 --- a/docs/api/functions/desc.html +++ b/docs/api/functions/desc.html @@ -1,2 +1,2 @@ desc | foy

Function desc

  • Define task description

    -

    Parameters

    • desc: string

    Returns void

+

Parameters

Returns void

diff --git a/docs/api/functions/exec.html b/docs/api/functions/exec.html index e8a5060..7d9fb63 100644 --- a/docs/api/functions/exec.html +++ b/docs/api/functions/exec.html @@ -1 +1 @@ -exec | foy

Function exec

+exec | foy

Function exec

diff --git a/docs/api/functions/execa-1.html b/docs/api/functions/execa-1.html index 14279cb..0db81d5 100644 --- a/docs/api/functions/execa-1.html +++ b/docs/api/functions/execa-1.html @@ -3,7 +3,7 @@

Parameters

Returns ExecaChildProcess<string>

A child_process instance, which is enhanced to also be a Promise for a result Object with stdout and stderr properties.

-
import execa = require('execa');

(async () => {
const {stdout} = await execa('echo', ['unicorns']);
console.log(stdout);
//=> 'unicorns'

// Cancelling a spawned process
const subprocess = execa('node');
setTimeout(() => { spawned.cancel() }, 1000);
try {
await subprocess;
} catch (error) {
console.log(subprocess.killed); // true
console.log(error.isCanceled); // true
}
})();

// Pipe the child process stdout to the current stdout
execa('echo', ['unicorns']).stdout.pipe(process.stdout); +
import execa = require('execa');

(async () => {
const {stdout} = await execa('echo', ['unicorns']);
console.log(stdout);
//=> 'unicorns'

// Cancelling a spawned process
const subprocess = execa('node');
setTimeout(() => { spawned.cancel() }, 1000);
try {
await subprocess;
} catch (error) {
console.log(subprocess.killed); // true
console.log(error.isCanceled); // true
}
})();

// Pipe the child process stdout to the current stdout
execa('echo', ['unicorns']).stdout.pipe(process.stdout);
  • Parameters

    • file: string
    • Optionalarguments: readonly string[]
    • Optionaloptions: Options<null>

    Returns ExecaChildProcess<Buffer>

  • Parameters

    • file: string
    • Optionaloptions: Options<string>

    Returns ExecaChildProcess<string>

  • Parameters

    • file: string
    • Optionaloptions: Options<null>

    Returns ExecaChildProcess<Buffer>

  • diff --git a/docs/api/functions/namespace.html b/docs/api/functions/namespace.html index ec65427..ac829f6 100644 --- a/docs/api/functions/namespace.html +++ b/docs/api/functions/namespace.html @@ -1,6 +1,6 @@ namespace | foy

    Function namespace

    • Create namespace prefix for inner tasks

      Parameters

      • ns: string

        namespace

        -
      • fn: ((ns: string) => void)
          • (ns): void
          • Parameters

            • ns: string

            Returns void

      Returns void

      namespace('client', ns => {
      task('run', async ctx => {
      logger.log(ns) // 'client'
      await ctx.exec('<run cmd>')
      })
      })
      namespace('server', ns => {
      task('run', async ctx => {
      logger.log(ns) // 'server'
      await ctx.exec('<run cmd>')
      })
      })

      ==========
      $ yarn foy client:run
      $ yarn foy server:run +
    • fn: ((ns: string) => void)
        • (ns): void
        • Parameters

          • ns: string

          Returns void

    Returns void

    namespace('client', ns => {
    task('run', async ctx => {
    logger.log(ns) // 'client'
    await ctx.exec('<run cmd>')
    })
    })
    namespace('server', ns => {
    task('run', async ctx => {
    logger.log(ns) // 'server'
    await ctx.exec('<run cmd>')
    })
    })

    ==========
    $ yarn foy client:run
    $ yarn foy server:run
    -
    +
    diff --git a/docs/api/functions/onerror.html b/docs/api/functions/onerror.html index 0bd7c18..e208dba 100644 --- a/docs/api/functions/onerror.html +++ b/docs/api/functions/onerror.html @@ -1 +1 @@ -onerror | foy

    Function onerror

    • Parameters

      • fn: ((err: Error, t: Task<any>) => void | Promise<void>)
          • (err, t): void | Promise<void>
          • Parameters

            • err: Error
            • t: Task<any>

            Returns void | Promise<void>

      Returns void

    +onerror | foy

    Function onerror

    • Parameters

      • fn: ((err: Error, t: Task<any>) => void | Promise<void>)
          • (err, t): void | Promise<void>
          • Parameters

            • err: Error
            • t: Task<any>

            Returns void | Promise<void>

      Returns void

    diff --git a/docs/api/functions/option.html b/docs/api/functions/option.html index d594d86..11ec1fe 100644 --- a/docs/api/functions/option.html +++ b/docs/api/functions/option.html @@ -1,2 +1,2 @@ option | foy

    Function option

    • Define a task cli option

      -

      Parameters

      • rawName: string
      • description: string
      • Optionalconfig: OptionConfig

      Returns void

    +

    Parameters

    • rawName: string
    • description: string
    • Optionalconfig: OptionConfig

    Returns void

    diff --git a/docs/api/functions/setGlobalOptions.html b/docs/api/functions/setGlobalOptions.html index 0aac445..e72e7eb 100644 --- a/docs/api/functions/setGlobalOptions.html +++ b/docs/api/functions/setGlobalOptions.html @@ -1,2 +1,2 @@ setGlobalOptions | foy

    Function setGlobalOptions

    • Set global options for all tasks.

      -

      Parameters

      Returns void

    +

    Parameters

    Returns void

    diff --git a/docs/api/functions/setOption.html b/docs/api/functions/setOption.html index 2ecd795..06b2c65 100644 --- a/docs/api/functions/setOption.html +++ b/docs/api/functions/setOption.html @@ -1,2 +1,2 @@ setOption | foy

    Function setOption

    • Set options for next task.

      -

      Parameters

      • options: Partial<{
            desc: undefined | string;
            loading: undefined | boolean;
            optionDefs: OptionDef[];
            strict: undefined | boolean;
        }>

      Returns void

    +

    Parameters

    • options: Partial<{
          desc: undefined | string;
          loading: undefined | boolean;
          optionDefs: OptionDef[];
          strict: undefined | boolean;
      }>

    Returns void

    diff --git a/docs/api/functions/shell.html b/docs/api/functions/shell.html index 4ef8ae4..bfee581 100644 --- a/docs/api/functions/shell.html +++ b/docs/api/functions/shell.html @@ -1 +1 @@ -shell | foy

    Function shell

    • Parameters

      Returns Promise<any>

    +shell | foy

    Function shell

    • Parameters

      Returns Promise<any>

    diff --git a/docs/api/functions/sleep.html b/docs/api/functions/sleep.html index 140612a..0a0c100 100644 --- a/docs/api/functions/sleep.html +++ b/docs/api/functions/sleep.html @@ -1 +1 @@ -sleep | foy

    Function sleep

    • Parameters

      • ms: number

      Returns Promise<void>

    +sleep | foy

    Function sleep

    • Parameters

      • ms: number

      Returns Promise<void>

    diff --git a/docs/api/functions/spawn.html b/docs/api/functions/spawn.html index 82f2bec..a71c182 100644 --- a/docs/api/functions/spawn.html +++ b/docs/api/functions/spawn.html @@ -3,10 +3,10 @@

    Parameters

    • file: string

      The program/script to execute.

    • Optionalarguments: readonly string[]

      Arguments to pass to file on execution.

    • Optionaloptions: Options<string>

    Returns ExecaChildProcess<string>

    A child_process instance, which is enhanced to also be a Promise for a result Object with stdout and stderr properties.

    -
    import execa = require('execa');

    (async () => {
    const {stdout} = await execa('echo', ['unicorns']);
    console.log(stdout);
    //=> 'unicorns'

    // Cancelling a spawned process
    const subprocess = execa('node');
    setTimeout(() => { spawned.cancel() }, 1000);
    try {
    await subprocess;
    } catch (error) {
    console.log(subprocess.killed); // true
    console.log(error.isCanceled); // true
    }
    })();

    // Pipe the child process stdout to the current stdout
    execa('echo', ['unicorns']).stdout.pipe(process.stdout); +
    import execa = require('execa');

    (async () => {
    const {stdout} = await execa('echo', ['unicorns']);
    console.log(stdout);
    //=> 'unicorns'

    // Cancelling a spawned process
    const subprocess = execa('node');
    setTimeout(() => { spawned.cancel() }, 1000);
    try {
    await subprocess;
    } catch (error) {
    console.log(subprocess.killed); // true
    console.log(error.isCanceled); // true
    }
    })();

    // Pipe the child process stdout to the current stdout
    execa('echo', ['unicorns']).stdout.pipe(process.stdout);
    -
  • Parameters

    • file: string
    • Optionalarguments: readonly string[]
    • Optionaloptions: Options<null>

    Returns ExecaChildProcess<Buffer>

  • Parameters

    • file: string
    • Optionaloptions: Options<string>

    Returns ExecaChildProcess<string>

  • Parameters

    • file: string
    • Optionaloptions: Options<null>

    Returns ExecaChildProcess<Buffer>

  • Methods

  • Parameters

    • file: string
    • Optionalarguments: readonly string[]
    • Optionaloptions: Options<null>

    Returns ExecaChildProcess<Buffer>

  • Parameters

    • file: string
    • Optionaloptions: Options<string>

    Returns ExecaChildProcess<string>

  • Parameters

    • file: string
    • Optionaloptions: Options<null>

    Returns ExecaChildProcess<Buffer>

  • Methods

    command commandSync node sync @@ -15,7 +15,7 @@

    The shell option must be used if the command uses shell-specific features, as opposed to being a simple file followed by its arguments.

    Parameters

    • command: string

      The program/script to execute and its arguments.

    • Optionaloptions: Options<string>

    Returns ExecaChildProcess<string>

    A child_process instance, which is enhanced to also be a Promise for a result Object with stdout and stderr properties.

    -
    import execa = require('execa');

    (async () => {
    const {stdout} = await execa.command('echo unicorns');
    console.log(stdout);
    //=> 'unicorns'
    })(); +
    import execa = require('execa');

    (async () => {
    const {stdout} = await execa.command('echo unicorns');
    console.log(stdout);
    //=> 'unicorns'
    })();
  • Parameters

    • command: string
    • Optionaloptions: Options<null>

    Returns ExecaChildProcess<Buffer>

    • Same as execa.command() but synchronous.

      diff --git a/docs/api/functions/strict.html b/docs/api/functions/strict.html index 05baefa..fc7a018 100644 --- a/docs/api/functions/strict.html +++ b/docs/api/functions/strict.html @@ -1,2 +1,2 @@ strict | foy

      Function strict

      • Define task cli options are strict, which means it will throw an error if you passed undefined options.

        -

        Returns void

      +

      Returns void

    diff --git a/docs/api/functions/task-1.html b/docs/api/functions/task-1.html index bc108c7..0a6f6e2 100644 --- a/docs/api/functions/task-1.html +++ b/docs/api/functions/task-1.html @@ -1,2 +1,2 @@ task | foy

    Function task

    Define a task

    -
    +
    diff --git a/docs/api/functions/throttle.html b/docs/api/functions/throttle.html index b8ec92b..ee6de6a 100644 --- a/docs/api/functions/throttle.html +++ b/docs/api/functions/throttle.html @@ -1 +1 @@ -throttle | foy

    Function throttle

    • Type Parameters

      • T extends ((...args: any[]) => void)

      Parameters

      • cb: T
      • ms: number
      • getArgsKey: ((args: any[]) => string) = ...
          • (args): string
          • Parameters

            • args: any[]

            Returns string

      Returns T

    +throttle | foy

    Function throttle

    • Type Parameters

      • T extends ((...args: any[]) => void)

      Parameters

      • cb: T
      • ms: number
      • getArgsKey: ((args: any[]) => string) = ...
          • (args): string
          • Parameters

            • args: any[]

            Returns string

      Returns T

    diff --git a/docs/api/index.html b/docs/api/index.html index f928c69..6111974 100644 --- a/docs/api/index.html +++ b/docs/api/index.html @@ -55,7 +55,7 @@

    which will create a simple Foyfile.js in the current folder:

    -
    // Foyfile.js
    const { task } = require('foy')

    task('build', async ctx => {
    await ctx.exec('tsc')
    }) +
    // Foyfile.js
    const { task } = require('foy')

    task('build', async ctx => {
    await ctx.exec('tsc')
    })

    You can also generate a Foyfile.ts via

    @@ -67,67 +67,67 @@

    You can also add some options and a description to your tasks:

    -
    import { task, desc, option, strict } from 'foy'

    desc('Build ts files with tsc')
    option('-w, --watch', 'watch file changes')
    strict() // This will throw an error if you passed some options that doesn't defined via `option()`
    task('build', async ctx => {
    await ctx.exec(`tsc ${ctx.options.watch ? '-w' : ''}`)
    }) +
    import { task, desc, option, strict } from 'foy'

    desc('Build ts files with tsc')
    option('-w, --watch', 'watch file changes')
    strict() // This will throw an error if you passed some options that doesn't defined via `option()`
    task('build', async ctx => {
    await ctx.exec(`tsc ${ctx.options.watch ? '-w' : ''}`)
    })

    And, if using TypeScript, add types to your options through the task generic:

    -
    import { task, desc, option, strict } from 'foy'

    type BuildOptions = {
    watch: boolean
    }

    desc('Build ts files with tsc')
    option('-w, --watch', 'watch file changes')
    strict() // This will throw an error if you passed some options that doesn't defined via `option()`
    task<BuildOptions>('build', async ctx => { // ctx.options now has type BuildOptions instead of unknown
    await ctx.exec(`tsc ${ctx.options.watch ? '-w' : ''}`)
    }) +
    import { task, desc, option, strict } from 'foy'

    type BuildOptions = {
    watch: boolean
    }

    desc('Build ts files with tsc')
    option('-w, --watch', 'watch file changes')
    strict() // This will throw an error if you passed some options that doesn't defined via `option()`
    task<BuildOptions>('build', async ctx => { // ctx.options now has type BuildOptions instead of unknown
    await ctx.exec(`tsc ${ctx.options.watch ? '-w' : ''}`)
    })
    foy build -w
     

    Warning! If you want to set flags like strict for all tasks, please use setGlobalOptions:

    -
    import { setGlobalOptions } from 'foy'

    setGlobalOptions({ strict: true }) // all tasks' options will be strict.

    option('-aa') // strict via default
    task('dev', async ctx => {

    })
    option('-bb') // strict via default
    task('build', async ctx => {

    })
    +
    import { setGlobalOptions } from 'foy'

    setGlobalOptions({ strict: true }) // all tasks' options will be strict.

    option('-aa') // strict via default
    task('dev', async ctx => {

    })
    option('-bb') // strict via default
    task('build', async ctx => {

    })
    -
    import { fs, task } from 'foy'

    task('some task', async ctx => {
    await fs.rmrf('/some/dir/or/file') // Remove directory or file
    await fs.copy('/src', '/dist') // Copy folder or file
    let json = await fs.readJson('./xx.json')
    await ctx
    .env('NODE_ENV', 'production')
    .cd('./src')
    .exec('some command') // Execute an command
    let { stdout } = await ctx.exec('ls', { stdio: 'pipe' }) // Get the stdout, default is empty because it's redirected to current process via `stdio: 'inherit'`.
    }) +
    import { fs, task } from 'foy'

    task('some task', async ctx => {
    await fs.rmrf('/some/dir/or/file') // Remove directory or file
    await fs.copy('/src', '/dist') // Copy folder or file
    let json = await fs.readJson('./xx.json')
    await ctx
    .env('NODE_ENV', 'production')
    .cd('./src')
    .exec('some command') // Execute an command
    let { stdout } = await ctx.exec('ls', { stdio: 'pipe' }) // Get the stdout, default is empty because it's redirected to current process via `stdio: 'inherit'`.
    })
    -
    import { task, logger } from 'foy'
    import * as axios from 'axios'

    task('build', async ctx => {
    let res = await axios.get('https://your.server/data.json')
    logger.info(res.data)
    }) +
    import { task, logger } from 'foy'
    import * as axios from 'axios'

    task('build', async ctx => {
    let res = await axios.get('https://your.server/data.json')
    logger.info(res.data)
    })
    -

    import { task } from 'foy'
    import * as axios from 'axios'

    task('test', async ctx => {
    await ctx.exec('mocha')
    })

    task('build', async ctx => {
    let res = await axios.get('https://your.server/data.json')
    console.log(res.data)
    await ctx.exec('build my awesome project')
    })
    task(
    'publish:patch',
    ['test', 'build'], // Run test and build before publish
    async ctx => {
    await ctx.exec('npm version patch')
    await ctx.exec('npm publish')
    }
    ) +

    import { task } from 'foy'
    import * as axios from 'axios'

    task('test', async ctx => {
    await ctx.exec('mocha')
    })

    task('build', async ctx => {
    let res = await axios.get('https://your.server/data.json')
    console.log(res.data)
    await ctx.exec('build my awesome project')
    })
    task(
    'publish:patch',
    ['test', 'build'], // Run test and build before publish
    async ctx => {
    await ctx.exec('npm version patch')
    await ctx.exec('npm publish')
    }
    )

    Dependencies run serially by default but you can specify when a task should be run concurrently.

    Example: Passing running options to dependencies:

    -
    task(
    'publish:patch',
    [{
    name: 'test',
    async: true, // run test parallelly
    force: true, // force rerun test whether it has been executed before or not.
    }, {
    name: 'build',
    async: true,
    force: true,
    },],
    async ctx => {
    await ctx.exec('npm version patch')
    await ctx.exec('npm publish')
    }
    )

    /* Sugar version */
    task(
    'publish:patch',
    [ 'test'.async().force(),
    'build'.async().force() ],
    async ctx => {
    await ctx.exec('npm version patch')
    await ctx.exec('npm publish')
    }
    )

    /*
    Priority for async tasks

    Default is 0, higher values will be run earlier; so, in this next example, `build` will be run before `test`.
    (Note: If you have multiple async dependencies with same priority, they will be executed in parallel.)
    */
    task(
    'publish:patch',
    [ 'test'.async(0).force(),
    'build'.async(1).force() ],
    async ctx => {
    await ctx.exec('npm version patch')
    await ctx.exec('npm publish')
    }
    ) +
    task(
    'publish:patch',
    [{
    name: 'test',
    async: true, // run test parallelly
    force: true, // force rerun test whether it has been executed before or not.
    }, {
    name: 'build',
    async: true,
    force: true,
    },],
    async ctx => {
    await ctx.exec('npm version patch')
    await ctx.exec('npm publish')
    }
    )

    /* Sugar version */
    task(
    'publish:patch',
    [ 'test'.async().force(),
    'build'.async().force() ],
    async ctx => {
    await ctx.exec('npm version patch')
    await ctx.exec('npm publish')
    }
    )

    /*
    Priority for async tasks

    Default is 0, higher values will be run earlier; so, in this next example, `build` will be run before `test`.
    (Note: If you have multiple async dependencies with same priority, they will be executed in parallel.)
    */
    task(
    'publish:patch',
    [ 'test'.async(0).force(),
    'build'.async(1).force() ],
    async ctx => {
    await ctx.exec('npm version patch')
    await ctx.exec('npm publish')
    }
    )

    You can also pass options to dependencies:

    -
    task('task1', async ctx => {
    console.log(ctx.options) // "{ forceRebuild: true, lazyOptions: 1 }"
    console.log(ctx.global.options) // options from command line "{ a: 1 }"
    })


    task('task2', [{
    name: 'task1',
    options: {
    forceRebuild: true,
    },
    // Some options that rely on ctx or asynchronization,
    // it will be merged to options.
    resolveOptions: async ctx => {
    return { lazyOptions: 1 }
    }
    }])

    // foy task2 -a 1 +
    task('task1', async ctx => {
    console.log(ctx.options) // "{ forceRebuild: true, lazyOptions: 1 }"
    console.log(ctx.global.options) // options from command line "{ a: 1 }"
    })


    task('task2', [{
    name: 'task1',
    options: {
    forceRebuild: true,
    },
    // Some options that rely on ctx or asynchronization,
    // it will be merged to options.
    resolveOptions: async ctx => {
    return { lazyOptions: 1 }
    }
    }])

    // foy task2 -a 1

    To avoid name collisions, Foy provides namespaces to group tasks via the namespace function:

    -
    import { task, namespace } from 'foy'

    namespace('client', ns => {
    before(() => {
    logger.info('before')
    })
    after(() => {
    logger.info('after')
    })
    onerror(() => {
    logger.info('onerror')
    })
    task('start', async ctx => { /* ... */ }) // client:start
    task('build', async ctx => { /* ... */ }) // client:build
    task('watch', async ctx => { /* ... */ }) // client:watch
    namespace('proj1', ns => { // nested namespace
    onerror(() => {
    logger.info('onerror', ns)
    })
    task('start', async ctx => { /* ... */ }) // client:proj1:start

    })
    })

    namespace('server', ns => {
    task('build', async ctx => { /* ... */ }) // server:build
    task('start', async ctx => { /* ... */ }) // server:start
    task('watch', async ctx => { /* ... */ }) // server:watch
    })

    task('start', ['client:start'.async(), 'server:start'.async()]) // start

    // foy start
    // foy client:build +
    import { task, namespace } from 'foy'

    namespace('client', ns => {
    before(() => {
    logger.info('before')
    })
    after(() => {
    logger.info('after')
    })
    onerror(() => {
    logger.info('onerror')
    })
    task('start', async ctx => { /* ... */ }) // client:start
    task('build', async ctx => { /* ... */ }) // client:build
    task('watch', async ctx => { /* ... */ }) // client:watch
    namespace('proj1', ns => { // nested namespace
    onerror(() => {
    logger.info('onerror', ns)
    })
    task('start', async ctx => { /* ... */ }) // client:proj1:start

    })
    })

    namespace('server', ns => {
    task('build', async ctx => { /* ... */ }) // server:build
    task('start', async ctx => { /* ... */ }) // server:start
    task('watch', async ctx => { /* ... */ }) // server:watch
    })

    task('start', ['client:start'.async(), 'server:start'.async()]) // start

    // foy start
    // foy client:build

    Foy wraps the NodeJS's fs (file system) module with a promise-based API, so you can easily use async/await patterns, if you prefer. Foy also implements some useful utility functions for build scripts not present in NodeJS's built-in modules.

    -
    import { fs } from 'foy'


    task('build', async ctx => {
    let f = await fs.readFileSync('./assets/someFile')

    // copy file or directory
    await fs.copy('./fromPath', './toPath')

    // watch a directory
    await fs.watchDir('./src', (event, filename) => {
    logger.info(event, filename)
    })

    // make directory with parent directories
    await fs.mkdirp('./some/directory/with/parents/not/exists')

    // write file will auto create missing parent directories
    await fs.outputFile('./some/file/with/parents/not/exists', 'file data')

    // write json file will auto create missing parent directories
    await fs.outputJson('./some/file/with/parents/not/exists', {text: 'json data'})
    let file = await fs.readJson('./some/jsonFile')

    // iterate directory tree
    await fs.iter('./src', async (path, stat) => {
    if (stat.isDirectory()) {
    logger.info('directory:', path)
    // skip scan node_modules
    if (path.endsWith('node_modules')) {
    return true
    }
    } else if (stat.isFile()) {
    logger.warn('file:', path)
    }
    })
    }) +
    import { fs } from 'foy'


    task('build', async ctx => {
    let f = await fs.readFileSync('./assets/someFile')

    // copy file or directory
    await fs.copy('./fromPath', './toPath')

    // watch a directory
    await fs.watchDir('./src', (event, filename) => {
    logger.info(event, filename)
    })

    // make directory with parent directories
    await fs.mkdirp('./some/directory/with/parents/not/exists')

    // write file will auto create missing parent directories
    await fs.outputFile('./some/file/with/parents/not/exists', 'file data')

    // write json file will auto create missing parent directories
    await fs.outputJson('./some/file/with/parents/not/exists', {text: 'json data'})
    let file = await fs.readJson('./some/jsonFile')

    // iterate directory tree
    await fs.iter('./src', async (path, stat) => {
    if (stat.isDirectory()) {
    logger.info('directory:', path)
    // skip scan node_modules
    if (path.endsWith('node_modules')) {
    return true
    }
    } else if (stat.isFile()) {
    logger.warn('file:', path)
    }
    })
    })

    Foy includes a light-weight built-in logger

    -
    import { logger } from 'foy'

    task('build', async ctx => {

    logger.debug('debug', { aa: 1})
    logger.info('info')
    logger.warn('warn')
    logger.error('error')

    })
    +
    import { logger } from 'foy'

    task('build', async ctx => {

    logger.debug('debug', { aa: 1})
    logger.info('info')
    logger.warn('warn')
    logger.error('error')

    })

    A simple wrapper for sindresorhus's lovely module execa

    -
    import { logger } from 'foy'

    task('build', async ctx => {
    await ctx.exec('tsc')

    // run multiple commands synchronously
    await ctx.exec([
    'tsc --outDir ./lib',
    'tsc --module es6 --outDir ./es',
    ])

    // run multiple commands concurrently
    await Promise.all([
    ctx.exec('eslint'),
    ctx.exec('tsc'),
    ctx.exec('typedoc'),
    ])
    // restart process when file changes
    ctx.monitor('./src', 'node ./dist')
    ctx.monitor('./src', ['rm -rf dist', 'tsc', 'node dist'])
    ctx.monitor('./src', async () => {
    await ctx.run('build:server')
    await ctx.exec('node ./dist') // auth detect long-running process when using ctx.exec
    })
    ctx.monitor('./src', async (p) => {
    // manually point out the process need to be killed when restart
    p.current = require('child_process').exec('node dist')
    })
    })

    +
    import { logger } from 'foy'

    task('build', async ctx => {
    await ctx.exec('tsc')

    // run multiple commands synchronously
    await ctx.exec([
    'tsc --outDir ./lib',
    'tsc --module es6 --outDir ./es',
    ])

    // run multiple commands concurrently
    await Promise.all([
    ctx.exec('eslint'),
    ctx.exec('tsc'),
    ctx.exec('typedoc'),
    ])
    // restart process when file changes
    ctx.monitor('./src', 'node ./dist')
    ctx.monitor('./src', ['rm -rf dist', 'tsc', 'node dist'])
    ctx.monitor('./src', async () => {
    await ctx.run('build:server')
    await ctx.exec('node ./dist') // auth detect long-running process when using ctx.exec
    })
    ctx.monitor('./src', async (p) => {
    // manually point out the process need to be killed when restart
    p.current = require('child_process').exec('node dist')
    })
    })

    If you use Foy in CI servers, you won't want the loading spinners as most CI servers will log stdout and stderr in discreet frames not meant for continuous streaming animations. Luckily, Foy has already considered this! You can simply disable the loading animation like this:

    -
    import { task, setGlobalOptions } from 'foy'

    setGlobalOptions({ loading: false }) // disable loading animations

    task('test', async cyx => { /* ... */ })
    /*
    $ foy test
    DependencyGraph for task [test]:
    ─ test

    Task: test
    ...
    */ +
    import { task, setGlobalOptions } from 'foy'

    setGlobalOptions({ loading: false }) // disable loading animations

    task('test', async cyx => { /* ... */ })
    /*
    $ foy test
    DependencyGraph for task [test]:
    ─ test

    Task: test
    ...
    */

    You can add lifecycle hooks via the before, after, and onerror functions.

    -
    import { before, after, onerror } from 'foy'
    before(() => { // do something before all tasks tree start
    // ...
    })
    after(() => { // do something after all tasks tree finished
    // ...
    })
    onerror((err) => { // do something when error happens
    // ...
    }) +
    import { before, after, onerror } from 'foy'
    before(() => { // do something before all tasks tree start
    // ...
    })
    after(() => { // do something after all tasks tree finished
    // ...
    })
    onerror((err) => { // do something when error happens
    // ...
    })
    -

    task('task1', async ctx => { /* ... */ })
    task('task2', async ctx => {
    // do things before task1

    // run task1 manually, so we can
    // do things before or after it
    await ctx.run('task1')

    // do things after task1
    })
    +

    task('task1', async ctx => { /* ... */ })
    task('task2', async ctx => {
    // do things before task1

    // run task1 manually, so we can
    // do things before or after it
    await ctx.run('task1')

    // do things after task1
    })
    -

    task('build', async ctx => { /* build your project */ })


    let p = null
    task('watch', async ctx => {
    ctx.monitor('./src', async ()=> {
    ctx.exec('node ./src/server.ts')
    })
    }) +

    task('build', async ctx => { /* build your project */ })


    let p = null
    task('watch', async ctx => {
    ctx.monitor('./src', async ()=> {
    ctx.exec('node ./src/server.ts')
    })
    })

    # Write Foyfile in ts, enabled by default
    foy -r ts-node/register -c ./some/Foyfile.ts build

    # Write Foyfile in coffee
    foy -r coffeescript/register -c ./some/Foyfile.coffee build
    diff --git a/docs/api/interfaces/GlobalOptions.html b/docs/api/interfaces/GlobalOptions.html index a122e92..7a66798 100644 --- a/docs/api/interfaces/GlobalOptions.html +++ b/docs/api/interfaces/GlobalOptions.html @@ -1,4 +1,4 @@ -GlobalOptions | foy

    Interface GlobalOptions

    interface GlobalOptions {
        indent?: number;
        loading?: boolean;
        logCommand?: boolean;
        logger?: ILoggerProps;
        options?: any;
        rawArgs?: string[];
        showTaskDuration?: boolean;
        strict?: boolean;
    }

    Properties

    indent? +GlobalOptions | foy

    Interface GlobalOptions

    interface GlobalOptions {
        indent?: number;
        loading?: boolean;
        logCommand?: boolean;
        logger?: ILoggerProps;
        options?: any;
        rawArgs?: string[];
        showTaskDuration?: boolean;
        strict?: boolean;
    }

    Properties

    indent?: number
    loading?: boolean
    true
    +

    Properties

    indent?: number
    loading?: boolean
    true
     
    -
    logCommand?: boolean
    logger?: ILoggerProps
    options?: any
    rawArgs?: string[]
    showTaskDuration?: boolean
    true
    +
    logCommand?: boolean
    logger?: ILoggerProps
    options?: any
    rawArgs?: string[]
    showTaskDuration?: boolean
    true
     
    -
    strict?: boolean

    Whether task options only allow defined options, default false

    +
    strict?: boolean

    Whether task options only allow defined options, default false

    false
     
    -
    +
    diff --git a/docs/api/interfaces/ILogInfo.html b/docs/api/interfaces/ILogInfo.html index ea3b863..114b28f 100644 --- a/docs/api/interfaces/ILogInfo.html +++ b/docs/api/interfaces/ILogInfo.html @@ -1,8 +1,8 @@ -ILogInfo | foy

    Interface ILogInfo

    interface ILogInfo {
        args: any[];
        filterLevelNum: number;
        formatedTime: string;
        level:
            | "error"
            | "debug"
            | "info"
            | "warn";
        levelNum: number;
        message: string;
        time: Date;
    }

    Properties

    args +ILogInfo | foy

    Interface ILogInfo

    interface ILogInfo {
        args: any[];
        filterLevelNum: number;
        formatedTime: string;
        level:
            | "error"
            | "debug"
            | "info"
            | "warn";
        levelNum: number;
        message: string;
        time: Date;
    }

    Properties

    args: any[]
    filterLevelNum: number
    formatedTime: string
    level:
        | "error"
        | "debug"
        | "info"
        | "warn"
    levelNum: number
    message: string
    time: Date
    +

    Properties

    args: any[]
    filterLevelNum: number
    formatedTime: string
    level:
        | "error"
        | "debug"
        | "info"
        | "warn"
    levelNum: number
    message: string
    time: Date
    diff --git a/docs/api/interfaces/ILoggerProps.html b/docs/api/interfaces/ILoggerProps.html index af726f5..d3ab4be 100644 --- a/docs/api/interfaces/ILoggerProps.html +++ b/docs/api/interfaces/ILoggerProps.html @@ -1,7 +1,7 @@ -ILoggerProps | foy

    Interface ILoggerProps

    interface ILoggerProps {
        hideConsole?: boolean;
        level?: string;
        levelColor?: {
            debug: ((v: string) => string);
            error: ((v: string) => string);
            info: ((v: string) => string);
            warn: ((v: string) => string);
        };
        logTime?: boolean | (() => string);
        format?(level: string, time: string, color: ((v: string) => string), args: any[]): string;
        onLog?(info: ILogInfo): void;
    }

    Properties

    hideConsole? +ILoggerProps | foy

    Interface ILoggerProps

    interface ILoggerProps {
        hideConsole?: boolean;
        level?: string;
        levelColor?: {
            debug: ((v: string) => string);
            error: ((v: string) => string);
            info: ((v: string) => string);
            warn: ((v: string) => string);
        };
        logTime?: boolean | (() => string);
        format?(level: string, time: string, color: ((v: string) => string), args: any[]): string;
        onLog?(info: ILogInfo): void;
    }

    Properties

    hideConsole?: boolean
    level?: string
    levelColor?: {
        debug: ((v: string) => string);
        error: ((v: string) => string);
        info: ((v: string) => string);
        warn: ((v: string) => string);
    }
    logTime?: boolean | (() => string)

    Methods

    • Parameters

      • level: string
      • time: string
      • color: ((v: string) => string)
          • (v): string
          • Parameters

            • v: string

            Returns string

      • args: any[]

      Returns string

    +

    Properties

    hideConsole?: boolean
    level?: string
    levelColor?: {
        debug: ((v: string) => string);
        error: ((v: string) => string);
        info: ((v: string) => string);
        warn: ((v: string) => string);
    }
    logTime?: boolean | (() => string)

    Methods

    • Parameters

      • level: string
      • time: string
      • color: ((v: string) => string)
          • (v): string
          • Parameters

            • v: string

            Returns string

      • args: any[]

      Returns string

    diff --git a/docs/api/interfaces/Task.html b/docs/api/interfaces/Task.html index e43e5c7..40b7a66 100644 --- a/docs/api/interfaces/Task.html +++ b/docs/api/interfaces/Task.html @@ -1,4 +1,4 @@ -Task | foy

    Interface Task<O>

    interface Task<O> {
        async?: number | boolean;
        dependencies?: TaskDep<any>[];
        desc?: string;
        fn?: ((ctx: TaskContext<O>) => void | Promise<void>);
        force?: boolean;
        loading?: boolean;
        logCommand?: boolean;
        logger?: ILoggerProps;
        name: string;
        namespaces: string[];
        options: O;
        rawArgs: string[];
        resolveOptions?: ((ctx: TaskContext<any>) => O | Promise<O>);
        strict?: boolean;
    }

    Type Parameters

    • O = any

    Hierarchy (view full)

    Properties

    async? +Task | foy

    Interface Task<O>

    interface Task<O> {
        async?: number | boolean;
        dependencies?: TaskDep<any>[];
        desc?: string;
        fn?: ((ctx: TaskContext<O>) => void | Promise<void>);
        force?: boolean;
        loading?: boolean;
        logCommand?: boolean;
        logger?: ILoggerProps;
        name: string;
        namespaces: string[];
        options: O;
        rawArgs: string[];
        resolveOptions?: ((ctx: TaskContext<any>) => O | Promise<O>);
        strict?: boolean;
    }

    Type Parameters

    • O = any

    Hierarchy (view full)

    Properties

    async? dependencies? desc? fn? @@ -16,19 +16,19 @@ If order doesn't matter and you want better performance via parallel, you can mark it as asynchronized. Asynchronized will run immediately whether there are synchronized tasks before them or not. You can pass a number as the priority of asynchronized tasks, bigger is formmer.

    -
    dependencies?: TaskDep<any>[]
    desc?: string
    fn?: ((ctx: TaskContext<O>) => void | Promise<void>)
    force?: boolean

    Whether rerun it when it occured in dependences tree more then once.

    -
    loading?: boolean

    whether show loading

    -
    globalOptions.loading
    +
    dependencies?: TaskDep<any>[]
    desc?: string
    fn?: ((ctx: TaskContext<O>) => void | Promise<void>)
    force?: boolean

    Whether rerun it when it occured in dependences tree more then once.

    +
    loading?: boolean

    whether show loading

    +
    globalOptions.loading
     
    -
    logCommand?: boolean

    whether log executed command

    -
    globalOptions.logCommand
    +
    logCommand?: boolean

    whether log executed command

    +
    globalOptions.logCommand
     
    -
    logger?: ILoggerProps
    name: string
    namespaces: string[]
    options: O

    Parsed options

    -
    rawArgs: string[]

    Raw arg strings

    -
    resolveOptions?: ((ctx: TaskContext<any>) => O | Promise<O>)
    strict?: boolean

    Whether task options only allow defined options, default false

    +
    logger?: ILoggerProps
    name: string
    namespaces: string[]
    options: O

    Parsed options

    +
    rawArgs: string[]

    Raw arg strings

    +
    resolveOptions?: ((ctx: TaskContext<any>) => O | Promise<O>)
    strict?: boolean

    Whether task options only allow defined options, default false

    false
     
    -
    +
    diff --git a/docs/api/interfaces/TaskDep.html b/docs/api/interfaces/TaskDep.html index 9827e07..9a99e1f 100644 --- a/docs/api/interfaces/TaskDep.html +++ b/docs/api/interfaces/TaskDep.html @@ -1,4 +1,4 @@ -TaskDep | foy

    Interface TaskDep<O>

    interface TaskDep<O> {
        async?: number | boolean;
        force?: boolean;
        name: string;
        options?: O;
        resolveOptions?: ((ctx: TaskContext<any>) => O | Promise<O>);
        [k: string]: any;
    }

    Type Parameters

    • O = any

    Hierarchy (view full)

    Indexable

    • [k: string]: any

    Properties

    async? +TaskDep | foy

    Interface TaskDep<O>

    interface TaskDep<O> {
        async?: number | boolean;
        force?: boolean;
        name: string;
        options?: O;
        resolveOptions?: ((ctx: TaskContext<any>) => O | Promise<O>);
        [k: string]: any;
    }

    Type Parameters

    • O = any

    Hierarchy (view full)

    Indexable

    • [k: string]: any

    Properties

    async? force? name options? @@ -7,6 +7,6 @@ If order doesn't matter and you want better performance via parallel, you can mark it as asynchronized. Asynchronized will run immediately whether there are synchronized tasks before them or not. You can pass a number as the priority of asynchronized tasks, bigger is formmer.

    -
    force?: boolean

    Whether rerun it when it occured in dependences tree more then once.

    -
    name: string
    options?: O

    Parsed options

    -
    resolveOptions?: ((ctx: TaskContext<any>) => O | Promise<O>)
    +
    force?: boolean

    Whether rerun it when it occured in dependences tree more then once.

    +
    name: string
    options?: O

    Parsed options

    +
    resolveOptions?: ((ctx: TaskContext<any>) => O | Promise<O>)
    diff --git a/docs/api/interfaces/WriteOptions.html b/docs/api/interfaces/WriteOptions.html index f91402f..f78714d 100644 --- a/docs/api/interfaces/WriteOptions.html +++ b/docs/api/interfaces/WriteOptions.html @@ -1,4 +1,4 @@ -WriteOptions | foy

    Interface WriteOptions

    interface WriteOptions {
        encoding?: BufferEncoding;
        flag?: string;
        mode?: string | number;
    }

    Properties

    encoding? +WriteOptions | foy

    Interface WriteOptions

    interface WriteOptions {
        encoding?: BufferEncoding;
        flag?: string;
        mode?: string | number;
    }

    Properties

    Properties

    encoding?: BufferEncoding
    flag?: string
    mode?: string | number
    +

    Properties

    encoding?: BufferEncoding
    flag?: string
    mode?: string | number
    diff --git a/docs/api/interfaces/execa.CommonOptions.html b/docs/api/interfaces/execa.CommonOptions.html index dd5e328..1db98e6 100644 --- a/docs/api/interfaces/execa.CommonOptions.html +++ b/docs/api/interfaces/execa.CommonOptions.html @@ -42,7 +42,7 @@
    cwd?: string

    Current working directory of the child process.

    -
    process.cwd()
    +
    process.cwd()
     
    detached?: boolean

    Prepare child to run independently of its parent process. Specific behavior depends on the platform.

    @@ -54,14 +54,14 @@
    env?: ProcessEnv

    Environment key-value pairs. Extends automatically from process.env. Set extendEnv to false if you don't want this.

    -
    process.env
    +
    process.env
     
    execPath?: string

    Path to the Node.js executable to use in child processes.

    This can be either an absolute path or a path relative to the cwd option.

    Requires preferLocal to be true.

    For example, this can be used together with get-node to run a specific Node.js version in a child process.

    -
    process.execPath
    +
    process.execPath
     
    extendEnv?: boolean

    Set to false if you don't want to extend the environment variables when providing the env property.

    @@ -74,11 +74,11 @@
    localDir?: string

    Preferred path to find locally installed binaries in (use with preferLocal).

    -
    process.cwd()
    +
    process.cwd()
     
    maxBuffer?: number

    Largest amount of data in bytes allowed on stdout or stderr. Default: 100 MB.

    -
    100_000_000
    +
    100_000_000
     
    preferLocal?: boolean

    Prefer locally installed binaries when looking for a binary to execute.

    @@ -129,7 +129,7 @@
    timeout?: number

    If timeout is greater than 0, the parent will send the signal identified by the killSignal property (the default is SIGTERM) if the child runs longer than timeout milliseconds.

    -
    0
    +
    0
     
    uid?: number

    Sets the user identity of the process.

    diff --git a/docs/api/interfaces/execa.KillOptions.html b/docs/api/interfaces/execa.KillOptions.html index 664f5db..11c4053 100644 --- a/docs/api/interfaces/execa.KillOptions.html +++ b/docs/api/interfaces/execa.KillOptions.html @@ -1,7 +1,7 @@ KillOptions | foy

    Interface KillOptions

    interface KillOptions {
        forceKillAfterTimeout?: number | false;
    }

    Properties

    forceKillAfterTimeout?: number | false

    Milliseconds to wait for the child process to terminate before sending SIGKILL.

    Can be disabled with false.

    -
    5000
    +
    5000
     
    diff --git a/docs/api/interfaces/execa.NodeOptions.html b/docs/api/interfaces/execa.NodeOptions.html index b9b5ef2..75146cd 100644 --- a/docs/api/interfaces/execa.NodeOptions.html +++ b/docs/api/interfaces/execa.NodeOptions.html @@ -45,7 +45,7 @@
    cwd?: string

    Current working directory of the child process.

    -
    process.cwd()
    +
    process.cwd()
     
    detached?: boolean

    Prepare child to run independently of its parent process. Specific behavior depends on the platform.

    @@ -57,14 +57,14 @@
    env?: ProcessEnv

    Environment key-value pairs. Extends automatically from process.env. Set extendEnv to false if you don't want this.

    -
    process.env
    +
    process.env
     
    execPath?: string

    Path to the Node.js executable to use in child processes.

    This can be either an absolute path or a path relative to the cwd option.

    Requires preferLocal to be true.

    For example, this can be used together with get-node to run a specific Node.js version in a child process.

    -
    process.execPath
    +
    process.execPath
     
    extendEnv?: boolean

    Set to false if you don't want to extend the environment variables when providing the env property.

    @@ -78,19 +78,19 @@
    localDir?: string

    Preferred path to find locally installed binaries in (use with preferLocal).

    -
    process.cwd()
    +
    process.cwd()
     
    maxBuffer?: number

    Largest amount of data in bytes allowed on stdout or stderr. Default: 100 MB.

    -
    100_000_000
    +
    100_000_000
     
    nodeOptions?: string[]

    List of CLI options passed to the Node.js executable.

    -
    process.execArgv
    +
    process.execArgv
     
    nodePath?: string

    The Node.js executable to use.

    -
    process.execPath
    +
    process.execPath
     
    preferLocal?: boolean

    Prefer locally installed binaries when looking for a binary to execute.

    @@ -141,7 +141,7 @@
    timeout?: number

    If timeout is greater than 0, the parent will send the signal identified by the killSignal property (the default is SIGTERM) if the child runs longer than timeout milliseconds.

    -
    0
    +
    0
     
    uid?: number

    Sets the user identity of the process.

    diff --git a/docs/api/interfaces/execa.Options.html b/docs/api/interfaces/execa.Options.html index 5dfcad4..6977c51 100644 --- a/docs/api/interfaces/execa.Options.html +++ b/docs/api/interfaces/execa.Options.html @@ -43,7 +43,7 @@
    cwd?: string

    Current working directory of the child process.

    -
    process.cwd()
    +
    process.cwd()
     
    detached?: boolean

    Prepare child to run independently of its parent process. Specific behavior depends on the platform.

    @@ -55,14 +55,14 @@
    env?: ProcessEnv

    Environment key-value pairs. Extends automatically from process.env. Set extendEnv to false if you don't want this.

    -
    process.env
    +
    process.env
     
    execPath?: string

    Path to the Node.js executable to use in child processes.

    This can be either an absolute path or a path relative to the cwd option.

    Requires preferLocal to be true.

    For example, this can be used together with get-node to run a specific Node.js version in a child process.

    -
    process.execPath
    +
    process.execPath
     
    extendEnv?: boolean

    Set to false if you don't want to extend the environment variables when providing the env property.

    @@ -76,11 +76,11 @@
    localDir?: string

    Preferred path to find locally installed binaries in (use with preferLocal).

    -
    process.cwd()
    +
    process.cwd()
     
    maxBuffer?: number

    Largest amount of data in bytes allowed on stdout or stderr. Default: 100 MB.

    -
    100_000_000
    +
    100_000_000
     
    preferLocal?: boolean

    Prefer locally installed binaries when looking for a binary to execute.

    @@ -131,7 +131,7 @@
    timeout?: number

    If timeout is greater than 0, the parent will send the signal identified by the killSignal property (the default is SIGTERM) if the child runs longer than timeout milliseconds.

    -
    0
    +
    0
     
    uid?: number

    Sets the user identity of the process.

    diff --git a/docs/api/interfaces/execa.SyncOptions.html b/docs/api/interfaces/execa.SyncOptions.html index 2c2c6ad..e223814 100644 --- a/docs/api/interfaces/execa.SyncOptions.html +++ b/docs/api/interfaces/execa.SyncOptions.html @@ -43,7 +43,7 @@
    cwd?: string

    Current working directory of the child process.

    -
    process.cwd()
    +
    process.cwd()
     
    detached?: boolean

    Prepare child to run independently of its parent process. Specific behavior depends on the platform.

    @@ -55,14 +55,14 @@
    env?: ProcessEnv

    Environment key-value pairs. Extends automatically from process.env. Set extendEnv to false if you don't want this.

    -
    process.env
    +
    process.env
     
    execPath?: string

    Path to the Node.js executable to use in child processes.

    This can be either an absolute path or a path relative to the cwd option.

    Requires preferLocal to be true.

    For example, this can be used together with get-node to run a specific Node.js version in a child process.

    -
    process.execPath
    +
    process.execPath
     
    extendEnv?: boolean

    Set to false if you don't want to extend the environment variables when providing the env property.

    @@ -76,11 +76,11 @@
    localDir?: string

    Preferred path to find locally installed binaries in (use with preferLocal).

    -
    process.cwd()
    +
    process.cwd()
     
    maxBuffer?: number

    Largest amount of data in bytes allowed on stdout or stderr. Default: 100 MB.

    -
    100_000_000
    +
    100_000_000
     
    preferLocal?: boolean

    Prefer locally installed binaries when looking for a binary to execute.

    @@ -131,7 +131,7 @@
    timeout?: number

    If timeout is greater than 0, the parent will send the signal identified by the killSignal property (the default is SIGTERM) if the child runs longer than timeout milliseconds.

    -
    0
    +
    0
     
    uid?: number

    Sets the user identity of the process.

    diff --git a/docs/api/types/Dependency.html b/docs/api/types/Dependency.html index 1e69df8..1bdec54 100644 --- a/docs/api/types/Dependency.html +++ b/docs/api/types/Dependency.html @@ -1 +1 @@ -Dependency | foy

    Type Alias Dependency

    Dependency: TaskDep | string | DepBuilder
    +Dependency | foy

    Type Alias Dependency

    Dependency: TaskDep | string | DepBuilder
    diff --git a/docs/api/types/LogLevels.html b/docs/api/types/LogLevels.html index b246f3a..b225bef 100644 --- a/docs/api/types/LogLevels.html +++ b/docs/api/types/LogLevels.html @@ -1 +1 @@ -LogLevels | foy

    Type Alias LogLevels

    LogLevels: keyof typeof LogLevels
    +LogLevels | foy

    Type Alias LogLevels

    LogLevels: keyof typeof LogLevels
    diff --git a/docs/api/types/TaskFn.html b/docs/api/types/TaskFn.html index 7c1bd74..dcb4fdb 100644 --- a/docs/api/types/TaskFn.html +++ b/docs/api/types/TaskFn.html @@ -1 +1 @@ -TaskFn | foy

    Type Alias TaskFn<O, T>

    TaskFn<O, T>: ((ctx: TaskContext<O>) => T | Promise<T>)

    Type Parameters

    • O
    • T = any
    +TaskFn | foy

    Type Alias TaskFn<O, T>

    TaskFn<O, T>: ((ctx: TaskContext<O>) => T | Promise<T>)

    Type Parameters

    • O
    • T = any
    diff --git a/docs/api/types/WatchDirHandler.html b/docs/api/types/WatchDirHandler.html index b0e2d1b..6283ba0 100644 --- a/docs/api/types/WatchDirHandler.html +++ b/docs/api/types/WatchDirHandler.html @@ -1 +1 @@ -WatchDirHandler | foy

    Type Alias WatchDirHandler

    WatchDirHandler: ((event: string, filename: string) => void)
    +WatchDirHandler | foy

    Type Alias WatchDirHandler

    WatchDirHandler: ((event: string, filename: string) => void)
    diff --git a/docs/api/types/WatchDirOptions.html b/docs/api/types/WatchDirOptions.html index 8c914b6..8f3304f 100644 --- a/docs/api/types/WatchDirOptions.html +++ b/docs/api/types/WatchDirOptions.html @@ -1,2 +1,2 @@ WatchDirOptions | foy

    Type Alias WatchDirOptions

    WatchDirOptions: {
        persistent?: boolean;
        threshold?: number;
    }

    Type declaration

    • Optionalpersistent?: boolean
    • Optionalthreshold?: number

      ms, default 300

      -
    +
    diff --git a/docs/api/variables/Is.html b/docs/api/variables/Is.html index 5f31f0f..c7ad0be 100644 --- a/docs/api/variables/Is.html +++ b/docs/api/variables/Is.html @@ -1 +1 @@ -Is | foy

    Variable IsConst

    Is: {
        bool(v: any): v is boolean;
        defed<T>(v: undefined | null | T): v is T;
        fn(v: any): v is Function;
        num(v: any): v is number;
        obj(v: any): v is object;
        str(v: any): v is string;
    } = ...
    +Is | foy

    Variable IsConst

    Is: {
        bool(v: any): v is boolean;
        defed<T>(v: undefined | null | T): v is T;
        fn(v: any): v is Function;
        num(v: any): v is number;
        obj(v: any): v is object;
        str(v: any): v is string;
    } = ...
    diff --git a/docs/api/variables/LogLevels-1.html b/docs/api/variables/LogLevels-1.html index 08c1bbd..735e21f 100644 --- a/docs/api/variables/LogLevels-1.html +++ b/docs/api/variables/LogLevels-1.html @@ -1 +1 @@ -LogLevels | foy

    Variable LogLevelsConst

    LogLevels: {
        debug: number;
        error: number;
        info: number;
        warn: number;
    } = ...
    +LogLevels | foy

    Variable LogLevelsConst

    LogLevels: {
        debug: number;
        error: number;
        info: number;
        warn: number;
    } = ...
    diff --git a/docs/api/variables/fs.html b/docs/api/variables/fs.html index eb155e2..d507fa9 100644 --- a/docs/api/variables/fs.html +++ b/docs/api/variables/fs.html @@ -1,9 +1,9 @@ fs | foy

    Variable fsConst

    fs: __module & __module & {
        copy: ((src: string, dist: string, opts?: {
            overwrite?: boolean;
            skip?: ((file: string, stat: Stats) => boolean | void | Promise<boolean | void>);
        }) => Promise<void>);
        copyFile: ((src: PathLike, dst: PathLike, flags?: number) => Promise<void>) | ((src: PathLike, dist: PathLike) => Promise<unknown>);
        watchDir: {
            (dir: string, cb: WatchDirHandler): void;
            (dir: string, options: WatchDirOptions, cb: WatchDirHandler): void;
        };
        exists(path: PathLike): Promise<boolean>;
        isDirectory(path: PathLike): Promise<boolean>;
        isFile(path: PathLike): Promise<boolean>;
        isSymbolicLink(path: PathLike): Promise<boolean>;
        iter(dir: string, skip: ((path: string, stat: Stats) => boolean | void | Promise<boolean | void>)): Promise<void>;
        lexists(path: PathLike): Promise<boolean>;
        mkdirp(dir: string): Promise<void>;
        mkdirpSync(dir: string): void;
        outputFile(path: string, data: any, options?: WriteOptions): Promise<void>;
        outputFileSync(path: string, data: any, options?: WriteOptions): void;
        outputJson(path: string, data: object, options?: {
            replacer?: ((key: string, value: any) => any);
            space?: number;
        } & WriteOptions): Promise<void>;
        outputJsonSync(path: string, data: any, options?: {
            replacer?: ((key: string, value: any) => any);
            space?: number;
        } & WriteOptions): void;
        readJson<T>(path: string, options?: null | {
            encoding?: null;
            flag?: string;
        }): Promise<T>;
        readJsonSync<T>(path: string, options?: null | {
            encoding?: null;
            flag?: string;
        }): T;
        rmrf(path: string): Promise<void>;
    } = ...

    Type declaration

    • copy: ((src: string, dist: string, opts?: {
          overwrite?: boolean;
          skip?: ((file: string, stat: Stats) => boolean | void | Promise<boolean | void>);
      }) => Promise<void>)
        • (src, dist, opts?): Promise<void>
        • Parameters

          • src: string
          • dist: string
          • Optionalopts: {
                overwrite?: boolean;
                skip?: ((file: string, stat: Stats) => boolean | void | Promise<boolean | void>);
            }
            • Optionaloverwrite?: boolean

              overwrite if exists, default is true

            • Optionalskip?: ((file: string, stat: Stats) => boolean | void | Promise<boolean | void>)

              return true will skip

              -
                • (file, stat): boolean | void | Promise<boolean | void>
                • Parameters

                  • file: string
                  • stat: Stats

                  Returns boolean | void | Promise<boolean | void>

          Returns Promise<void>

    • copyFile: ((src: PathLike, dst: PathLike, flags?: number) => Promise<void>) | ((src: PathLike, dist: PathLike) => Promise<unknown>)
    • watchDir: {
          (dir: string, cb: WatchDirHandler): void;
          (dir: string, options: WatchDirOptions, cb: WatchDirHandler): void;
      }
    • exists:function
      • Parameters

        • path: PathLike

        Returns Promise<boolean>

    • isDirectory:function
      • Parameters

        • path: PathLike

        Returns Promise<boolean>

    • isFile:function
      • Parameters

        • path: PathLike

        Returns Promise<boolean>

    • isSymbolicLink:function
      • Parameters

        • path: PathLike

        Returns Promise<boolean>

    • iter:function
      • Parameters

        • dir: string
        • skip: ((path: string, stat: Stats) => boolean | void | Promise<boolean | void>)

          return true will skip

          -
            • (path, stat): boolean | void | Promise<boolean | void>
            • Parameters

              • path: string
              • stat: Stats

              Returns boolean | void | Promise<boolean | void>

        Returns Promise<void>

    • lexists:function
      • exists via lstat, if a symbolic link's target file doesn't exists, fs.exists will return false, but fs.lexists will return true.

        -

        Parameters

        • path: PathLike

        Returns Promise<boolean>

    • mkdirp:function
      • Make directory with parents, like mkdir -p

        -

        Parameters

        • dir: string

        Returns Promise<void>

    • mkdirpSync:function
      • Make directory with parents, like mkdir -p

        -

        Parameters

        • dir: string

        Returns void

    • outputFile:function
      • Parameters

        Returns Promise<void>

    • outputFileSync:function
      • Parameters

        Returns void

    • outputJson:function
      • Parameters

        • path: string
        • data: object
        • Optionaloptions: {
              replacer?: ((key: string, value: any) => any);
              space?: number;
          } & WriteOptions

        Returns Promise<void>

    • outputJsonSync:function
      • Parameters

        • path: string
        • data: any
        • Optionaloptions: {
              replacer?: ((key: string, value: any) => any);
              space?: number;
          } & WriteOptions

        Returns void

    • readJson:function
      • Type Parameters

        • T = any

        Parameters

        • path: string
        • Optionaloptions: null | {
              encoding?: null;
              flag?: string;
          }

        Returns Promise<T>

    • readJsonSync:function
      • Type Parameters

        • T = any

        Parameters

        • path: string
        • Optionaloptions: null | {
              encoding?: null;
              flag?: string;
          }

        Returns T

    • rmrf:function
      • Remove file or directory recursively, like rm -rf

        +
          • (file, stat): boolean | void | Promise<boolean | void>
          • Parameters

            • file: string
            • stat: Stats

            Returns boolean | void | Promise<boolean | void>

    Returns Promise<void>

  • copyFile: ((src: PathLike, dst: PathLike, flags?: number) => Promise<void>) | ((src: PathLike, dist: PathLike) => Promise<unknown>)
  • watchDir: {
        (dir: string, cb: WatchDirHandler): void;
        (dir: string, options: WatchDirOptions, cb: WatchDirHandler): void;
    }
  • exists:function
    • Parameters

      • path: PathLike

      Returns Promise<boolean>

  • isDirectory:function
    • Parameters

      • path: PathLike

      Returns Promise<boolean>

  • isFile:function
    • Parameters

      • path: PathLike

      Returns Promise<boolean>

  • isSymbolicLink:function
    • Parameters

      • path: PathLike

      Returns Promise<boolean>

  • iter:function
    • Parameters

      • dir: string
      • skip: ((path: string, stat: Stats) => boolean | void | Promise<boolean | void>)

        return true will skip

        +
          • (path, stat): boolean | void | Promise<boolean | void>
          • Parameters

            • path: string
            • stat: Stats

            Returns boolean | void | Promise<boolean | void>

      Returns Promise<void>

  • lexists:function
    • exists via lstat, if a symbolic link's target file doesn't exists, fs.exists will return false, but fs.lexists will return true.

      +

      Parameters

      • path: PathLike

      Returns Promise<boolean>

  • mkdirp:function
    • Make directory with parents, like mkdir -p

      +

      Parameters

      • dir: string

      Returns Promise<void>

  • mkdirpSync:function
    • Make directory with parents, like mkdir -p

      +

      Parameters

      • dir: string

      Returns void

  • outputFile:function
    • Parameters

      Returns Promise<void>

  • outputFileSync:function
    • Parameters

      Returns void

  • outputJson:function
    • Parameters

      • path: string
      • data: object
      • Optionaloptions: {
            replacer?: ((key: string, value: any) => any);
            space?: number;
        } & WriteOptions

      Returns Promise<void>

  • outputJsonSync:function
    • Parameters

      • path: string
      • data: any
      • Optionaloptions: {
            replacer?: ((key: string, value: any) => any);
            space?: number;
        } & WriteOptions

      Returns void

  • readJson:function
    • Type Parameters

      • T = any

      Parameters

      • path: string
      • Optionaloptions: null | {
            encoding?: null;
            flag?: string;
        }

      Returns Promise<T>

  • readJsonSync:function
    • Type Parameters

      • T = any

      Parameters

      • path: string
      • Optionaloptions: null | {
            encoding?: null;
            flag?: string;
        }

      Returns T

  • rmrf:function
    • Remove file or directory recursively, like rm -rf

      Parameters

      • path: string

        The path to remove

        -

      Returns Promise<void>

  • +

    Returns Promise<void>

    diff --git a/docs/api/variables/logger-1.html b/docs/api/variables/logger-1.html index 347ccd4..b7a5514 100644 --- a/docs/api/variables/logger-1.html +++ b/docs/api/variables/logger-1.html @@ -1 +1 @@ -logger | foy

    Variable loggerConst

    logger: Logger = ...
    +logger | foy

    Variable loggerConst

    logger: Logger = ...