@sequencemedia/gulp-cli 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Blaine Bublitz, Eric Schoffstall and other contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ <p align="center">
2
+ <a href="http://gulpjs.com">
3
+ <img width="114" src="https://raw.githubusercontent.com/gulpjs/artwork/master/gulp-2x.png">
4
+ </a>
5
+ </p>
6
+
7
+ # @sequencemedia/gulp-cli
8
+
9
+ This project is a fork of Gulp CLI `v2.3.0` refactored in ESM and updated with latest dependencies
10
+
11
+ ## Documentation
12
+
13
+ Refer to [documentation at the Gulp website](https://gulpjs.com/docs/en/getting-started/quick-start)
package/bin/gulp.mjs ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ import gulpCli from '#gulp-cli'
4
+
5
+ export default gulpCli()
@@ -0,0 +1,20 @@
1
+ # Completion for gulp
2
+ > Thanks to the grunt team, specifically Tyler Kellen
3
+
4
+ To enable tasks auto-completion in shell you should add `eval "$(gulp --completion=shell)"` in your `.shellrc` file.
5
+
6
+ ## Bash
7
+
8
+ Add `eval "$(gulp --completion=bash)"` to `~/.bashrc`.
9
+
10
+ ## Zsh
11
+
12
+ Add `eval "$(gulp --completion=zsh)"` to `~/.zshrc`.
13
+
14
+ ## Powershell
15
+
16
+ Add `Invoke-Expression ((gulp --completion=powershell) -join [System.Environment]::NewLine)` to `$PROFILE`.
17
+
18
+ ## Fish
19
+
20
+ Add `gulp --completion=fish | source` to `~/.config/fish/config.fish`.
@@ -0,0 +1,27 @@
1
+ #!/bin/bash
2
+
3
+ # Borrowed from grunt-cli
4
+ # http://gruntjs.com/
5
+ #
6
+ # Copyright (c) 2012 Tyler Kellen, contributors
7
+ # Licensed under the MIT license.
8
+ # https://github.com/gruntjs/grunt/blob/master/LICENSE-MIT
9
+
10
+ # Usage:
11
+ #
12
+ # To enable bash <tab> completion for gulp, add the following line (minus the
13
+ # leading #, which is the bash comment character) to your ~/.bashrc file:
14
+ #
15
+ # eval "$(gulp --completion=bash)"
16
+
17
+ # Enable bash autocompletion.
18
+ function _gulp_completions() {
19
+ # The currently-being-completed word.
20
+ local cur="${COMP_WORDS[COMP_CWORD]}"
21
+ #Grab tasks
22
+ local compls=$(gulp --tasks-list)
23
+ # Tell complete what stuff to show.
24
+ COMPREPLY=($(compgen -W "$compls" -- "$cur"))
25
+ }
26
+
27
+ complete -o default -F _gulp_completions gulp
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env fish
2
+
3
+ # Usage:
4
+ #
5
+ # To enable fish <tab> completion for gulp, add the following line to
6
+ # your ~/.config/fish/config.fish file:
7
+ #
8
+ # gulp --completion=fish | source
9
+
10
+ complete -c gulp -a "(gulp --tasks-list)" -f
@@ -0,0 +1,61 @@
1
+ # Copyright (c) 2014 Jason Jarrett
2
+ #
3
+ # Tab completion for the `gulp`
4
+ #
5
+ # Usage:
6
+ #
7
+ # To enable powershell <tab> completion for gulp you need to be running
8
+ # at least PowerShell v3 or greater and add the below to your $PROFILE
9
+ #
10
+ # Invoke-Expression ((gulp --completion=powershell) -join [System.Environment]::NewLine)
11
+ #
12
+ #
13
+
14
+ $gulp_completion_Process = {
15
+ param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameter)
16
+
17
+
18
+ # Load up an assembly to read the gulpfile's sha1
19
+ if(-not $global:GulpSHA1Managed) {
20
+ [Reflection.Assembly]::LoadWithPartialName("System.Security") | out-null
21
+ $global:GulpSHA1Managed = new-Object System.Security.Cryptography.SHA1Managed
22
+ }
23
+
24
+ # setup a global (in-memory) cache
25
+ if(-not $global:GulpfileShaCache) {
26
+ $global:GulpfileShaCache = @{};
27
+ }
28
+
29
+ $cache = $global:GulpfileShaCache;
30
+
31
+ # Get the gulpfile's sha1
32
+ $sha1gulpFile = (resolve-path gulpfile.js -ErrorAction Ignore | %{
33
+ $file = [System.IO.File]::Open($_.Path, "open", "read")
34
+ [string]::join('', ($global:GulpSHA1Managed.ComputeHash($file) | %{ $_.ToString("x2") }))
35
+ $file.Dispose()
36
+ })
37
+
38
+ # lookup the sha1 for previously cached task lists.
39
+ if($cache.ContainsKey($sha1gulpFile)){
40
+ $tasks = $cache[$sha1gulpFile];
41
+ } else {
42
+ $tasks = (gulp --tasks-list).split("`n");
43
+ $cache[$sha1gulpFile] = $tasks;
44
+ }
45
+
46
+
47
+ $tasks |
48
+ where { $_.startswith($commandName) }
49
+ Sort-Object |
50
+ foreach { New-Object System.Management.Automation.CompletionResult $_, $_, 'ParameterValue', ('{0}' -f $_) }
51
+ }
52
+
53
+ if (-not $global:options) {
54
+ $global:options = @{
55
+ CustomArgumentCompleters = @{};
56
+ NativeArgumentCompleters = @{}
57
+ }
58
+ }
59
+
60
+ $global:options['NativeArgumentCompleters']['gulp'] = $gulp_completion_Process
61
+ $function:tabexpansion2 = $function:tabexpansion2 -replace 'End\r\n{','End { if ($null -ne $options) { $options += $global:options} else {$options = $global:options}'
package/completion/zsh ADDED
@@ -0,0 +1,25 @@
1
+ #!/bin/zsh
2
+
3
+ # Borrowed from grunt-cli
4
+ # http://gruntjs.com/
5
+ #
6
+ # Copyright (c) 2012 Tyler Kellen, contributors
7
+ # Licensed under the MIT license.
8
+ # https://github.com/gruntjs/grunt/blob/master/LICENSE-MIT
9
+
10
+ # Usage:
11
+ #
12
+ # To enable zsh <tab> completion for gulp, add the following line (minus the
13
+ # leading #, which is the zsh comment character) to your ~/.zshrc file:
14
+ #
15
+ # eval "$(gulp --completion=zsh)"
16
+
17
+ # Enable zsh autocompletion.
18
+ function _gulp_completion() {
19
+ # Grab tasks
20
+ compls=$(gulp --tasks-list)
21
+ completions=(${=compls})
22
+ compadd -- $completions
23
+ }
24
+
25
+ compdef _gulp_completion gulp
package/gulp.1 ADDED
@@ -0,0 +1,83 @@
1
+ .TH "GULP" "" "April 2023" "" ""
2
+ .SH "NAME"
3
+ \fBgulp\fR
4
+ .SS Usage
5
+ .P
6
+ \fBgulp [flags] <task> <task>\.\.\.\fP
7
+ .SS Tasks
8
+ .P
9
+ The task(s) listed will be executed\.
10
+ If more than one task is listed, Gulp will execute all of them
11
+ concurrently, that is, as if they had all been listed as dependencies of
12
+ a single task\.
13
+ .P
14
+ By default, Gulp does not serialize tasks listed on the command line\. If you would like to execute tasks serially, you must specify the \fB\-\-series\fP flag\. e\.g\. \fBgulp clean build \-\-series\fP
15
+ .P
16
+ Just running \fBgulp\fP will execute the task \fBdefault\fP\|\. If there is no
17
+ \fBdefault\fP task, gulp will error\.
18
+ .SS Compilers
19
+ .P
20
+ You can find a list of supported languages at https:// \fIhttps://github\.com/gulpjs/interpret\fR\|\. If you would like to add support for a new language, send pull requests/open issues on that project\.
21
+ .SS Environment
22
+ .P
23
+ The CLI adds process\.env\.INIT_CWD which is the original cwd it was launched from\.
24
+ .SS Flags
25
+ .P
26
+ gulp has very few flags to know about\. All other flags are for tasks to use if needed\.
27
+ .P
28
+ \fBSome flags only work with gulp 4 and will be ignored when invoked against gulp 3\.\fR
29
+ .P
30
+ \fB\-\-help\fR, \fB\-h\fR
31
+ Show the help\.
32
+ .P
33
+ \fB\-\-version\fR, \fB\-v\fR
34
+ Print the global and local gulp versions\.
35
+ .P
36
+ \fB\-\-require\fR [path]
37
+ Will require a module before running the gulpfile\. This is useful for transpilers but also has other applications\.
38
+ .P
39
+ \fB\-\-gulpfile\fR [path], \fB\-f\fR [path]
40
+ Manually set path of gulpfile\. Useful if you have multiple gulpfiles\. This will set the CWD to the gulpfile directory as well\.
41
+ .P
42
+ \fB\-\-cwd\fR [path]
43
+ Manually set the CWD\. The search for the gulpfile, as well as the relativity of all requires will be from here\.
44
+ .P
45
+ \fB\-\-verify\fR [path (optional)]
46
+ Will verify plugins referenced in project's package\.json against the plugins blacklist\.
47
+ .P
48
+ \fB\-\-tasks\fR, \fB\-T\fR
49
+ Print the task dependency tree for the loaded gulpfile\.
50
+ .P
51
+ \fB\-\-tasks\-simple\fR
52
+ Print a plaintext list of tasks for the loaded gulpfile\.
53
+ .P
54
+ \fB\-\-tasks\-json\fR [path]
55
+ Print the task dependency tree, in JSON format, for the loaded gulpfile\. The [path] argument is optional, and if given writes the JSON to the path\.
56
+ .P
57
+ \fB\-\-tasks\-depth\fR [number]
58
+ Specify the depth of the task dependency tree to print\. This flag can be used with \-\-tasks or \-\-tasks\-json\. (This flag was named \-\-depth before but is deprecated\.)
59
+ .P
60
+ \fB\-\-compact\-tasks\fR
61
+ Reduce the output of task dependency tree by printing only top tasks and their child tasks\. This flag can be used with \-\-tasks or \-\-tasks\-json\.
62
+ .P
63
+ \fB\-\-sort\-tasks\fR
64
+ Will sort top tasks of task dependency tree\. This flag can be used with \-\-tasks\.
65
+ .P
66
+ \fB\-\-color\fR
67
+ Will force gulp and gulp plugins to display colors, even when no color support is detected\.
68
+ .P
69
+ \fB\-\-no\-color\fR
70
+ Will force gulp and gulp plugins to not display colors, even when color support is detected\.
71
+ .P
72
+ \fB\-\-silent\fR, \fB\-S\fR
73
+ Suppress all gulp logging\.
74
+ .P
75
+ \fB\-\-continue\fR
76
+ Continue execution of tasks upon failure\.
77
+ .P
78
+ \fB\-\-series\fR
79
+ Run tasks given on the CLI in series (the default is parallel)\.
80
+ .P
81
+ \fB\-\-log\-level\fR, \fB\-L\fR
82
+ Set the loglevel\. \-L for least verbose and \-LLLL for most verbose\. \-LLL is default\.
83
+
package/index.mjs ADDED
@@ -0,0 +1,140 @@
1
+
2
+ import path from 'node:path'
3
+ import log from 'gulplog'
4
+ import yargs from 'yargs'
5
+ import {
6
+ hideBin
7
+ } from 'yargs/helpers'
8
+ import Liftoff from '@sequencemedia/liftoff'
9
+ import interpret from 'interpret'
10
+ import v8flags from 'v8flags'
11
+
12
+ import ansi from './lib/ansi.mjs'
13
+ import exit from './lib/exit.mjs'
14
+ import tildify from './lib/tildify.mjs'
15
+ import getProcessTitle from './lib/get-process-title.mjs'
16
+ import cliOptions from './lib/cli-options.mjs'
17
+ import getCompletion from './lib/get-completion.mjs'
18
+
19
+ import listenForLevelEvents from './lib/log/listen-for-level-events.mjs'
20
+
21
+ import loadConfigFiles from './lib/config/load-files.mjs'
22
+ import mergeConfigToCliFlags from './lib/config/cli-flags.mjs'
23
+ import mergeConfigToEnvFlags from './lib/config/env-flags.mjs'
24
+
25
+ import runVersion from './lib/run-version.mjs'
26
+ import runVerify from './lib/run-verify.mjs'
27
+ import run from './lib/index.mjs'
28
+
29
+ // Set env var for ORIGINAL cwd
30
+ // before anything touches it
31
+ const INIT_CWD = process.cwd()
32
+ process.env.INIT_CWD = INIT_CWD
33
+
34
+ const cli = new Liftoff({
35
+ name: 'gulp',
36
+ configName: 'gulpfile',
37
+ moduleName: '@sequencemedia/gulp',
38
+ processTitle: getProcessTitle(process.argv.slice(2)),
39
+ completions: getCompletion,
40
+ extensions: interpret.jsVariants,
41
+ v8flags,
42
+ configFiles: {
43
+ '.gulp': {
44
+ home: {
45
+ path: '~',
46
+ extensions: interpret.extensions
47
+ },
48
+ cwd: {
49
+ path: '.',
50
+ extensions: interpret.extensions
51
+ }
52
+ }
53
+ }
54
+ })
55
+
56
+ let {
57
+ argv: cliProps
58
+ } = (
59
+ yargs(hideBin(process.argv))
60
+ .version(false)
61
+ .usage(`${ansi.bold('Usage')}: $0 ${ansi.blue('[options]')} tasks`)
62
+ .options(cliOptions)
63
+ )
64
+
65
+ cli.on('require', (name) => {
66
+ // This is needed because interpret needs to stub the .mjs extension
67
+ // Without the .mjs require hook, rechoir blows up
68
+ // However, we don't want to show the mjs-stub loader in the logs
69
+ if (path.basename(name, '.js') !== 'mjs-stub') {
70
+ log.info('Loading external module', ansi.magenta(name))
71
+ }
72
+ })
73
+
74
+ cli.on('requireFail', (name, error) => {
75
+ log.warn(`${ansi.yellow('Failed to load external module')} ${ansi.magenta(name)}`)
76
+
77
+ if (error) {
78
+ log.warn(ansi.yellow(error.toString()))
79
+ }
80
+ })
81
+
82
+ cli.on('respawn', (nodeFlags, { pid }) => {
83
+ log.info(`Node flags detected: ${ansi.magenta(nodeFlags.join(', '))}`)
84
+ log.info(`Respawned to PID: ${ansi.magenta(pid)}`)
85
+ })
86
+
87
+ function execute (envProps, cliProps, configProps) {
88
+ /**
89
+ * Does not depend on Gulp
90
+ */
91
+ if (cliProps.version) return runVersion(envProps, cliProps)
92
+
93
+ /**
94
+ * Does not depend on Gulp
95
+ */
96
+ if (cliProps.verify) return runVerify(envProps, cliProps)
97
+
98
+ /**
99
+ * Depends on Gulp
100
+ */
101
+ const GULP_CWD = path.normalize(envProps.cwd)
102
+ process.env.GULP_CWD = GULP_CWD
103
+
104
+ if (!envProps.modulePath) {
105
+ log.error(`${ansi.red('Gulp not found')} in ${ansi.magenta(tildify(GULP_CWD))}`)
106
+ exit(1)
107
+ }
108
+
109
+ if (!envProps.configPath) {
110
+ log.error(`${ansi.red('Gulpfile not found')} in ${ansi.magenta(tildify(GULP_CWD))}`)
111
+ exit(1)
112
+ }
113
+
114
+ if (cliProps.continue) process.env.UNDERTAKER_SETTLE = 'true'
115
+
116
+ if (INIT_CWD !== GULP_CWD) process.chdir(GULP_CWD)
117
+
118
+ return (
119
+ run(cliProps, envProps, configProps)
120
+ )
121
+ }
122
+
123
+ export default function prepare () {
124
+ cli.prepare({
125
+ cwd: cliProps.cwd,
126
+ configPath: cliProps.gulpfile,
127
+ require: cliProps.require,
128
+ completion: cliProps.completion
129
+ }, async (envProps) => {
130
+ const configProps = await loadConfigFiles(envProps.configFiles['.gulp'], ['home', 'cwd'])
131
+
132
+ cliProps = mergeConfigToCliFlags(cliProps, configProps)
133
+ envProps = mergeConfigToEnvFlags(envProps, configProps, cliProps)
134
+
135
+ // Set up log level event listeners
136
+ listenForLevelEvents(cliProps)
137
+
138
+ cli.execute(envProps, envProps.nodeFlags, (envProps) => execute(envProps, cliProps, configProps))
139
+ })
140
+ }
package/lib/ansi.mjs ADDED
@@ -0,0 +1,46 @@
1
+ import ansiColors from 'ansi-colors'
2
+ import colorSupport from 'color-support'
3
+
4
+ const HAS_NO_COLOR = process.argv.includes('--no-color')
5
+ const HAS_COLOR = process.argv.includes('--color')
6
+ const HAS_COLOR_SUPPORT = hasColorSupport(colorSupport())
7
+
8
+ function hasColorSupport ({ hasBasic, has256, has16m }) {
9
+ return (
10
+ hasBasic ||
11
+ has256 ||
12
+ has16m
13
+ )
14
+ }
15
+
16
+ function hasColor () {
17
+ if (HAS_NO_COLOR) {
18
+ return false
19
+ }
20
+
21
+ return (
22
+ HAS_COLOR ||
23
+ HAS_COLOR_SUPPORT
24
+ )
25
+ }
26
+
27
+ function noColor (message) {
28
+ return message
29
+ }
30
+
31
+ export default (
32
+ hasColor()
33
+ ? ansiColors
34
+ : {
35
+ red: noColor,
36
+ green: noColor,
37
+ blue: noColor,
38
+ magenta: noColor,
39
+ cyan: noColor,
40
+ white: noColor,
41
+ gray: noColor,
42
+ bgred: noColor,
43
+ bold: noColor,
44
+ yellow: noColor
45
+ }
46
+ )
@@ -0,0 +1,120 @@
1
+ import ansi from './ansi.mjs'
2
+
3
+ export default {
4
+ help: {
5
+ alias: 'h',
6
+ type: 'boolean',
7
+ desc: ansi.gray(
8
+ 'Show this help.')
9
+ },
10
+ version: {
11
+ alias: 'v',
12
+ type: 'boolean',
13
+ desc: ansi.gray(
14
+ 'Print the global and local gulp versions.')
15
+ },
16
+ require: {
17
+ type: 'string',
18
+ requiresArg: true,
19
+ desc: ansi.gray(
20
+ 'Will require a module before running the gulpfile. ' +
21
+ 'This is useful for transpilers but also has other applications.')
22
+ },
23
+ gulpfile: {
24
+ alias: 'f',
25
+ type: 'string',
26
+ requiresArg: true,
27
+ desc: ansi.gray(
28
+ 'Manually set path of gulpfile. Useful if you have multiple gulpfiles. ' +
29
+ 'This will set the CWD to the gulpfile directory as well.')
30
+ },
31
+ cwd: {
32
+ type: 'string',
33
+ requiresArg: true,
34
+ desc: ansi.gray(
35
+ 'Manually set the CWD. The search for the gulpfile, ' +
36
+ 'as well as the relativity of all requires will be from here.')
37
+ },
38
+ verify: {
39
+ desc: ansi.gray(
40
+ 'Will verify plugins referenced in project\'s package.json against ' +
41
+ 'the plugins blacklist.')
42
+ },
43
+ tasks: {
44
+ alias: 'T',
45
+ type: 'boolean',
46
+ desc: ansi.gray(
47
+ 'Print the task dependency tree for the loaded gulpfile.')
48
+ },
49
+ 'tasks-list': {
50
+ type: 'boolean',
51
+ desc: ansi.gray(
52
+ 'Print a list of tasks for the loaded gulpfile.')
53
+ },
54
+ 'tasks-json': {
55
+ desc: ansi.gray(
56
+ 'Print the task dependency tree, ' +
57
+ 'in JSON format, for the loaded gulpfile.')
58
+ },
59
+ 'tasks-depth': {
60
+ alias: 'depth',
61
+ type: 'number',
62
+ requiresArg: true,
63
+ default: undefined, // To detect if this cli option is specified.
64
+ desc: ansi.gray(
65
+ 'Specify the depth of the task dependency tree.')
66
+ },
67
+ 'compact-tasks': {
68
+ type: 'boolean',
69
+ default: undefined, // To detect if this cli option is specified.
70
+ desc: ansi.gray(
71
+ 'Reduce the output of task dependency tree by printing ' +
72
+ 'only top tasks and their child tasks.')
73
+ },
74
+ 'sort-tasks': {
75
+ type: 'boolean',
76
+ default: undefined, // To detect if this cli option is specified.
77
+ desc: ansi.gray(
78
+ 'Will sort top tasks of task dependency tree.')
79
+ },
80
+ color: {
81
+ type: 'boolean',
82
+ desc: ansi.gray(
83
+ 'Will force gulp and gulp plugins to display colors, ' +
84
+ 'even when no color support is detected.')
85
+ },
86
+ 'no-color': {
87
+ type: 'boolean',
88
+ desc: ansi.gray(
89
+ 'Will force gulp and gulp plugins to not display colors, ' +
90
+ 'even when color support is detected.')
91
+ },
92
+ silent: {
93
+ alias: 'S',
94
+ type: 'boolean',
95
+ default: undefined, // To detect if this cli option is specified.
96
+ desc: ansi.gray(
97
+ 'Suppress all gulp logging.')
98
+ },
99
+ continue: {
100
+ type: 'boolean',
101
+ default: undefined, // To detect if this cli option is specified.
102
+ desc: ansi.gray(
103
+ 'Continue execution of tasks upon failure.')
104
+ },
105
+ series: {
106
+ type: 'boolean',
107
+ default: undefined, // To detect if this cli option is specified.
108
+ desc: ansi.gray(
109
+ 'Run tasks given on the CLI in series (the default is parallel).')
110
+ },
111
+ 'log-level': {
112
+ alias: 'L',
113
+ // Type isn't needed because count acts as a boolean
114
+ count: true,
115
+ default: undefined, // To detect if this cli option is specified.
116
+ desc: ansi.gray(
117
+ 'Set the loglevel. -L for least verbose and -LLLL for most verbose. ' +
118
+ '-LLL is default.')
119
+ }
120
+ }
@@ -0,0 +1,21 @@
1
+ import copyProps from 'copy-props'
2
+
3
+ const fromTo = {
4
+ 'flags.silent': 'silent',
5
+ 'flags.continue': 'continue',
6
+ 'flags.series': 'series',
7
+ 'flags.logLevel': 'logLevel',
8
+ 'flags.compactTasks': 'compactTasks',
9
+ 'flags.tasksDepth': 'tasksDepth',
10
+ 'flags.sortTasks': 'sortTasks'
11
+ }
12
+
13
+ export default function mergeConfigToCliFlags (cliProps, configProps) {
14
+ return (
15
+ copyProps(configProps, cliProps, fromTo, (configProps, cliProps) => {
16
+ if (cliProps.value === undefined) {
17
+ return configProps.value
18
+ }
19
+ })
20
+ )
21
+ }
@@ -0,0 +1,41 @@
1
+ import path from 'node:path'
2
+ import copyProps from 'copy-props'
3
+
4
+ const toFrom = {
5
+ configPath: 'flags.gulpfile',
6
+ configBase: 'flags.gulpfile',
7
+ require: 'flags.require',
8
+ nodeFlags: 'flags.nodeFlags'
9
+ }
10
+
11
+ function getConvert (cliProps) {
12
+ return function convert (config, env) {
13
+ if (env.keyChain === 'configBase') {
14
+ if (cliProps.gulpfile === undefined) {
15
+ return path.dirname(config.value)
16
+ }
17
+ return
18
+ }
19
+
20
+ if (env.keyChain === 'configPath') {
21
+ if (cliProps.gulpfile === undefined) {
22
+ return config.value
23
+ }
24
+ return
25
+ }
26
+
27
+ if (env.keyChain === 'require') {
28
+ return [].concat(env.value, config.value)
29
+ }
30
+
31
+ if (env.keyChain === 'nodeFlags') {
32
+ return [].concat(config.value || [])
33
+ }
34
+ }
35
+ }
36
+
37
+ export default function mergeConfigToEnvFlags (envProps, configProps, cliProps) {
38
+ return (
39
+ copyProps(envProps, configProps, toFrom, getConvert(cliProps), true) // This must reverse because `flags.gulpfile` determines 2 different properties
40
+ )
41
+ }