@eclipse-glsp/cli 2.7.0-next.8 → 2.7.0-next.9

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/dist/cli.js CHANGED
@@ -3667,1206 +3667,6 @@ var require_brace_expansion = __commonJS({
3667
3667
  }
3668
3668
  });
3669
3669
 
3670
- // ../../node_modules/readline-sync/lib/readline-sync.js
3671
- var require_readline_sync = __commonJS({
3672
- "../../node_modules/readline-sync/lib/readline-sync.js"(exports2) {
3673
- "use strict";
3674
- var IS_WIN = process.platform === "win32";
3675
- var ALGORITHM_CIPHER = "aes-256-cbc";
3676
- var ALGORITHM_HASH = "sha256";
3677
- var DEFAULT_ERR_MSG = "The current environment doesn't support interactive reading from TTY.";
3678
- var fs10 = require("fs");
3679
- var TTY = process.binding("tty_wrap").TTY;
3680
- var childProc = require("child_process");
3681
- var pathUtil = require("path");
3682
- var defaultOptions = {
3683
- /* eslint-disable key-spacing */
3684
- prompt: "> ",
3685
- hideEchoBack: false,
3686
- mask: "*",
3687
- limit: [],
3688
- limitMessage: "Input another, please.$<( [)limit(])>",
3689
- defaultInput: "",
3690
- trueValue: [],
3691
- falseValue: [],
3692
- caseSensitive: false,
3693
- keepWhitespace: false,
3694
- encoding: "utf8",
3695
- bufferSize: 1024,
3696
- print: void 0,
3697
- history: true,
3698
- cd: false,
3699
- phContent: void 0,
3700
- preCheck: void 0
3701
- /* eslint-enable key-spacing */
3702
- };
3703
- var fdR = "none";
3704
- var isRawMode = false;
3705
- var salt = 0;
3706
- var lastInput = "";
3707
- var inputHistory = [];
3708
- var _DBG_useExt = false;
3709
- var _DBG_checkOptions = false;
3710
- var _DBG_checkMethod = false;
3711
- var fdW;
3712
- var ttyR;
3713
- var extHostPath;
3714
- var extHostArgs;
3715
- var tempdir;
3716
- var rawInput;
3717
- function getHostArgs(options) {
3718
- function encodeArg(arg) {
3719
- return arg.replace(/[^\w\u0080-\uFFFF]/g, function(chr) {
3720
- return "#" + chr.charCodeAt(0) + ";";
3721
- });
3722
- }
3723
- return extHostArgs.concat((function(conf) {
3724
- var args = [];
3725
- Object.keys(conf).forEach(function(optionName) {
3726
- if (conf[optionName] === "boolean") {
3727
- if (options[optionName]) {
3728
- args.push("--" + optionName);
3729
- }
3730
- } else if (conf[optionName] === "string") {
3731
- if (options[optionName]) {
3732
- args.push("--" + optionName, encodeArg(options[optionName]));
3733
- }
3734
- }
3735
- });
3736
- return args;
3737
- })({
3738
- /* eslint-disable key-spacing */
3739
- display: "string",
3740
- displayOnly: "boolean",
3741
- keyIn: "boolean",
3742
- hideEchoBack: "boolean",
3743
- mask: "string",
3744
- limit: "string",
3745
- caseSensitive: "boolean"
3746
- /* eslint-enable key-spacing */
3747
- }));
3748
- }
3749
- function _execFileSync(options, execOptions) {
3750
- function getTempfile(name) {
3751
- var suffix = "", filepath, fd;
3752
- tempdir = tempdir || require("os").tmpdir();
3753
- while (true) {
3754
- filepath = pathUtil.join(tempdir, name + suffix);
3755
- try {
3756
- fd = fs10.openSync(filepath, "wx");
3757
- } catch (e) {
3758
- if (e.code === "EEXIST") {
3759
- suffix++;
3760
- continue;
3761
- } else {
3762
- throw e;
3763
- }
3764
- }
3765
- fs10.closeSync(fd);
3766
- break;
3767
- }
3768
- return filepath;
3769
- }
3770
- var res = {}, pathStdout = getTempfile("readline-sync.stdout"), pathStderr = getTempfile("readline-sync.stderr"), pathExit = getTempfile("readline-sync.exit"), pathDone = getTempfile("readline-sync.done"), crypto = require("crypto"), hostArgs, shellPath, shellArgs, exitCode, extMessage, shasum, decipher, password;
3771
- shasum = crypto.createHash(ALGORITHM_HASH);
3772
- shasum.update("" + process.pid + salt++ + Math.random());
3773
- password = shasum.digest("hex");
3774
- decipher = crypto.createDecipher(ALGORITHM_CIPHER, password);
3775
- hostArgs = getHostArgs(options);
3776
- if (IS_WIN) {
3777
- shellPath = process.env.ComSpec || "cmd.exe";
3778
- process.env.Q = '"';
3779
- shellArgs = [
3780
- "/V:ON",
3781
- "/S",
3782
- "/C",
3783
- "(%Q%" + shellPath + "%Q% /V:ON /S /C %Q%%Q%" + extHostPath + "%Q%" + hostArgs.map(function(arg) {
3784
- return " %Q%" + arg + "%Q%";
3785
- }).join("") + " & (echo !ERRORLEVEL!)>%Q%" + pathExit + "%Q%%Q%) 2>%Q%" + pathStderr + "%Q% |%Q%" + process.execPath + "%Q% %Q%" + __dirname + "\\encrypt.js%Q% %Q%" + ALGORITHM_CIPHER + "%Q% %Q%" + password + "%Q% >%Q%" + pathStdout + "%Q% & (echo 1)>%Q%" + pathDone + "%Q%"
3786
- ];
3787
- } else {
3788
- shellPath = "/bin/sh";
3789
- shellArgs = [
3790
- "-c",
3791
- // Use `()`, not `{}` for `-c` (text param)
3792
- '("' + extHostPath + '"' + /* ESLint bug? */
3793
- // eslint-disable-line no-path-concat
3794
- hostArgs.map(function(arg) {
3795
- return " '" + arg.replace(/'/g, "'\\''") + "'";
3796
- }).join("") + '; echo $?>"' + pathExit + '") 2>"' + pathStderr + '" |"' + process.execPath + '" "' + __dirname + '/encrypt.js" "' + ALGORITHM_CIPHER + '" "' + password + '" >"' + pathStdout + '"; echo 1 >"' + pathDone + '"'
3797
- ];
3798
- }
3799
- if (_DBG_checkMethod) {
3800
- _DBG_checkMethod("_execFileSync", hostArgs);
3801
- }
3802
- try {
3803
- childProc.spawn(shellPath, shellArgs, execOptions);
3804
- } catch (e) {
3805
- res.error = new Error(e.message);
3806
- res.error.method = "_execFileSync - spawn";
3807
- res.error.program = shellPath;
3808
- res.error.args = shellArgs;
3809
- }
3810
- while (fs10.readFileSync(pathDone, { encoding: options.encoding }).trim() !== "1") {
3811
- }
3812
- if ((exitCode = fs10.readFileSync(pathExit, { encoding: options.encoding }).trim()) === "0") {
3813
- res.input = decipher.update(
3814
- fs10.readFileSync(pathStdout, { encoding: "binary" }),
3815
- "hex",
3816
- options.encoding
3817
- ) + decipher.final(options.encoding);
3818
- } else {
3819
- extMessage = fs10.readFileSync(pathStderr, { encoding: options.encoding }).trim();
3820
- res.error = new Error(DEFAULT_ERR_MSG + (extMessage ? "\n" + extMessage : ""));
3821
- res.error.method = "_execFileSync";
3822
- res.error.program = shellPath;
3823
- res.error.args = shellArgs;
3824
- res.error.extMessage = extMessage;
3825
- res.error.exitCode = +exitCode;
3826
- }
3827
- fs10.unlinkSync(pathStdout);
3828
- fs10.unlinkSync(pathStderr);
3829
- fs10.unlinkSync(pathExit);
3830
- fs10.unlinkSync(pathDone);
3831
- return res;
3832
- }
3833
- function readlineExt(options) {
3834
- var res = {}, execOptions = { env: process.env, encoding: options.encoding }, hostArgs, extMessage;
3835
- if (!extHostPath) {
3836
- if (IS_WIN) {
3837
- if (process.env.PSModulePath) {
3838
- extHostPath = "powershell.exe";
3839
- extHostArgs = [
3840
- "-ExecutionPolicy",
3841
- "Bypass",
3842
- "-File",
3843
- __dirname + "\\read.ps1"
3844
- ];
3845
- } else {
3846
- extHostPath = "cscript.exe";
3847
- extHostArgs = ["//nologo", __dirname + "\\read.cs.js"];
3848
- }
3849
- } else {
3850
- extHostPath = "/bin/sh";
3851
- extHostArgs = [__dirname + "/read.sh"];
3852
- }
3853
- }
3854
- if (IS_WIN && !process.env.PSModulePath) {
3855
- execOptions.stdio = [process.stdin];
3856
- }
3857
- if (childProc.execFileSync) {
3858
- hostArgs = getHostArgs(options);
3859
- if (_DBG_checkMethod) {
3860
- _DBG_checkMethod("execFileSync", hostArgs);
3861
- }
3862
- try {
3863
- res.input = childProc.execFileSync(extHostPath, hostArgs, execOptions);
3864
- } catch (e) {
3865
- extMessage = e.stderr ? (e.stderr + "").trim() : "";
3866
- res.error = new Error(DEFAULT_ERR_MSG + (extMessage ? "\n" + extMessage : ""));
3867
- res.error.method = "execFileSync";
3868
- res.error.program = extHostPath;
3869
- res.error.args = hostArgs;
3870
- res.error.extMessage = extMessage;
3871
- res.error.exitCode = e.status;
3872
- res.error.code = e.code;
3873
- res.error.signal = e.signal;
3874
- }
3875
- } else {
3876
- res = _execFileSync(options, execOptions);
3877
- }
3878
- if (!res.error) {
3879
- res.input = res.input.replace(/^\s*'|'\s*$/g, "");
3880
- options.display = "";
3881
- }
3882
- return res;
3883
- }
3884
- function _readlineSync(options) {
3885
- var input = "", displaySave = options.display, silent = !options.display && options.keyIn && options.hideEchoBack && !options.mask;
3886
- function tryExt() {
3887
- var res = readlineExt(options);
3888
- if (res.error) {
3889
- throw res.error;
3890
- }
3891
- return res.input;
3892
- }
3893
- if (_DBG_checkOptions) {
3894
- _DBG_checkOptions(options);
3895
- }
3896
- (function() {
3897
- var fsB, constants, verNum;
3898
- function getFsB() {
3899
- if (!fsB) {
3900
- fsB = process.binding("fs");
3901
- constants = process.binding("constants");
3902
- constants = constants && constants.fs && typeof constants.fs.O_RDWR === "number" ? constants.fs : constants;
3903
- }
3904
- return fsB;
3905
- }
3906
- if (typeof fdR !== "string") {
3907
- return;
3908
- }
3909
- fdR = null;
3910
- if (IS_WIN) {
3911
- verNum = (function(ver) {
3912
- var nums = ver.replace(/^\D+/, "").split(".");
3913
- var verNum2 = 0;
3914
- if (nums[0] = +nums[0]) {
3915
- verNum2 += nums[0] * 1e4;
3916
- }
3917
- if (nums[1] = +nums[1]) {
3918
- verNum2 += nums[1] * 100;
3919
- }
3920
- if (nums[2] = +nums[2]) {
3921
- verNum2 += nums[2];
3922
- }
3923
- return verNum2;
3924
- })(process.version);
3925
- if (!(verNum >= 20302 && verNum < 40204 || verNum >= 5e4 && verNum < 50100 || verNum >= 50600 && verNum < 60200) && process.stdin.isTTY) {
3926
- process.stdin.pause();
3927
- fdR = process.stdin.fd;
3928
- ttyR = process.stdin._handle;
3929
- } else {
3930
- try {
3931
- fdR = getFsB().open("CONIN$", constants.O_RDWR, parseInt("0666", 8));
3932
- ttyR = new TTY(fdR, true);
3933
- } catch (e) {
3934
- }
3935
- }
3936
- if (process.stdout.isTTY) {
3937
- fdW = process.stdout.fd;
3938
- } else {
3939
- try {
3940
- fdW = fs10.openSync("\\\\.\\CON", "w");
3941
- } catch (e) {
3942
- }
3943
- if (typeof fdW !== "number") {
3944
- try {
3945
- fdW = getFsB().open("CONOUT$", constants.O_RDWR, parseInt("0666", 8));
3946
- } catch (e) {
3947
- }
3948
- }
3949
- }
3950
- } else {
3951
- if (process.stdin.isTTY) {
3952
- process.stdin.pause();
3953
- try {
3954
- fdR = fs10.openSync("/dev/tty", "r");
3955
- ttyR = process.stdin._handle;
3956
- } catch (e) {
3957
- }
3958
- } else {
3959
- try {
3960
- fdR = fs10.openSync("/dev/tty", "r");
3961
- ttyR = new TTY(fdR, false);
3962
- } catch (e) {
3963
- }
3964
- }
3965
- if (process.stdout.isTTY) {
3966
- fdW = process.stdout.fd;
3967
- } else {
3968
- try {
3969
- fdW = fs10.openSync("/dev/tty", "w");
3970
- } catch (e) {
3971
- }
3972
- }
3973
- }
3974
- })();
3975
- (function() {
3976
- var isCooked = !options.hideEchoBack && !options.keyIn, atEol, limit, buffer, reqSize, readSize, chunk, line;
3977
- rawInput = "";
3978
- function setRawMode(mode) {
3979
- if (mode === isRawMode) {
3980
- return true;
3981
- }
3982
- if (ttyR.setRawMode(mode) !== 0) {
3983
- return false;
3984
- }
3985
- isRawMode = mode;
3986
- return true;
3987
- }
3988
- if (_DBG_useExt || !ttyR || typeof fdW !== "number" && (options.display || !isCooked)) {
3989
- input = tryExt();
3990
- return;
3991
- }
3992
- if (options.display) {
3993
- fs10.writeSync(fdW, options.display);
3994
- options.display = "";
3995
- }
3996
- if (options.displayOnly) {
3997
- return;
3998
- }
3999
- if (!setRawMode(!isCooked)) {
4000
- input = tryExt();
4001
- return;
4002
- }
4003
- reqSize = options.keyIn ? 1 : options.bufferSize;
4004
- buffer = Buffer.allocUnsafe && Buffer.alloc ? Buffer.alloc(reqSize) : new Buffer(reqSize);
4005
- if (options.keyIn && options.limit) {
4006
- limit = new RegExp(
4007
- "[^" + options.limit + "]",
4008
- "g" + (options.caseSensitive ? "" : "i")
4009
- );
4010
- }
4011
- while (true) {
4012
- readSize = 0;
4013
- try {
4014
- readSize = fs10.readSync(fdR, buffer, 0, reqSize);
4015
- } catch (e) {
4016
- if (e.code !== "EOF") {
4017
- setRawMode(false);
4018
- input += tryExt();
4019
- return;
4020
- }
4021
- }
4022
- if (readSize > 0) {
4023
- chunk = buffer.toString(options.encoding, 0, readSize);
4024
- rawInput += chunk;
4025
- } else {
4026
- chunk = "\n";
4027
- rawInput += String.fromCharCode(0);
4028
- }
4029
- if (chunk && typeof (line = (chunk.match(/^(.*?)[\r\n]/) || [])[1]) === "string") {
4030
- chunk = line;
4031
- atEol = true;
4032
- }
4033
- if (chunk) {
4034
- chunk = chunk.replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f]/g, "");
4035
- }
4036
- if (chunk && limit) {
4037
- chunk = chunk.replace(limit, "");
4038
- }
4039
- if (chunk) {
4040
- if (!isCooked) {
4041
- if (!options.hideEchoBack) {
4042
- fs10.writeSync(fdW, chunk);
4043
- } else if (options.mask) {
4044
- fs10.writeSync(fdW, new Array(chunk.length + 1).join(options.mask));
4045
- }
4046
- }
4047
- input += chunk;
4048
- }
4049
- if (!options.keyIn && atEol || options.keyIn && input.length >= reqSize) {
4050
- break;
4051
- }
4052
- }
4053
- if (!isCooked && !silent) {
4054
- fs10.writeSync(fdW, "\n");
4055
- }
4056
- setRawMode(false);
4057
- })();
4058
- if (options.print && !silent) {
4059
- options.print(
4060
- displaySave + (options.displayOnly ? "" : (options.hideEchoBack ? new Array(input.length + 1).join(options.mask) : input) + "\n"),
4061
- options.encoding
4062
- );
4063
- }
4064
- return options.displayOnly ? "" : lastInput = options.keepWhitespace || options.keyIn ? input : input.trim();
4065
- }
4066
- function flattenArray(array, validator) {
4067
- var flatArray = [];
4068
- function _flattenArray(array2) {
4069
- if (array2 == null) {
4070
- return;
4071
- }
4072
- if (Array.isArray(array2)) {
4073
- array2.forEach(_flattenArray);
4074
- } else if (!validator || validator(array2)) {
4075
- flatArray.push(array2);
4076
- }
4077
- }
4078
- _flattenArray(array);
4079
- return flatArray;
4080
- }
4081
- function escapePattern(pattern) {
4082
- return pattern.replace(
4083
- /[\x00-\x7f]/g,
4084
- // eslint-disable-line no-control-regex
4085
- function(s) {
4086
- return "\\x" + ("00" + s.charCodeAt().toString(16)).substr(-2);
4087
- }
4088
- );
4089
- }
4090
- function margeOptions() {
4091
- var optionsList = Array.prototype.slice.call(arguments), optionNames, fromDefault;
4092
- if (optionsList.length && typeof optionsList[0] === "boolean") {
4093
- fromDefault = optionsList.shift();
4094
- if (fromDefault) {
4095
- optionNames = Object.keys(defaultOptions);
4096
- optionsList.unshift(defaultOptions);
4097
- }
4098
- }
4099
- return optionsList.reduce(function(options, optionsPart) {
4100
- if (optionsPart == null) {
4101
- return options;
4102
- }
4103
- if (optionsPart.hasOwnProperty("noEchoBack") && !optionsPart.hasOwnProperty("hideEchoBack")) {
4104
- optionsPart.hideEchoBack = optionsPart.noEchoBack;
4105
- delete optionsPart.noEchoBack;
4106
- }
4107
- if (optionsPart.hasOwnProperty("noTrim") && !optionsPart.hasOwnProperty("keepWhitespace")) {
4108
- optionsPart.keepWhitespace = optionsPart.noTrim;
4109
- delete optionsPart.noTrim;
4110
- }
4111
- if (!fromDefault) {
4112
- optionNames = Object.keys(optionsPart);
4113
- }
4114
- optionNames.forEach(function(optionName) {
4115
- var value;
4116
- if (!optionsPart.hasOwnProperty(optionName)) {
4117
- return;
4118
- }
4119
- value = optionsPart[optionName];
4120
- switch (optionName) {
4121
- // _readlineSync <- * * -> defaultOptions
4122
- // ================ string
4123
- case "mask":
4124
- // * *
4125
- case "limitMessage":
4126
- // *
4127
- case "defaultInput":
4128
- // *
4129
- case "encoding":
4130
- value = value != null ? value + "" : "";
4131
- if (value && optionName !== "limitMessage") {
4132
- value = value.replace(/[\r\n]/g, "");
4133
- }
4134
- options[optionName] = value;
4135
- break;
4136
- // ================ number(int)
4137
- case "bufferSize":
4138
- if (!isNaN(value = parseInt(value, 10)) && typeof value === "number") {
4139
- options[optionName] = value;
4140
- }
4141
- break;
4142
- // ================ boolean
4143
- case "displayOnly":
4144
- // *
4145
- case "keyIn":
4146
- // *
4147
- case "hideEchoBack":
4148
- // * *
4149
- case "caseSensitive":
4150
- // * *
4151
- case "keepWhitespace":
4152
- // * *
4153
- case "history":
4154
- // *
4155
- case "cd":
4156
- options[optionName] = !!value;
4157
- break;
4158
- // ================ array
4159
- case "limit":
4160
- // * * to string for readlineExt
4161
- case "trueValue":
4162
- // *
4163
- case "falseValue":
4164
- options[optionName] = flattenArray(value, function(value2) {
4165
- var type = typeof value2;
4166
- return type === "string" || type === "number" || type === "function" || value2 instanceof RegExp;
4167
- }).map(function(value2) {
4168
- return typeof value2 === "string" ? value2.replace(/[\r\n]/g, "") : value2;
4169
- });
4170
- break;
4171
- // ================ function
4172
- case "print":
4173
- // * *
4174
- case "phContent":
4175
- // *
4176
- case "preCheck":
4177
- options[optionName] = typeof value === "function" ? value : void 0;
4178
- break;
4179
- // ================ other
4180
- case "prompt":
4181
- // *
4182
- case "display":
4183
- options[optionName] = value != null ? value : "";
4184
- break;
4185
- }
4186
- });
4187
- return options;
4188
- }, {});
4189
- }
4190
- function isMatched(res, comps, caseSensitive) {
4191
- return comps.some(function(comp) {
4192
- var type = typeof comp;
4193
- return type === "string" ? caseSensitive ? res === comp : res.toLowerCase() === comp.toLowerCase() : type === "number" ? parseFloat(res) === comp : type === "function" ? comp(res) : comp instanceof RegExp ? comp.test(res) : false;
4194
- });
4195
- }
4196
- function replaceHomePath(path13, expand2) {
4197
- var homePath = pathUtil.normalize(
4198
- IS_WIN ? (process.env.HOMEDRIVE || "") + (process.env.HOMEPATH || "") : process.env.HOME || ""
4199
- ).replace(/[/\\]+$/, "");
4200
- path13 = pathUtil.normalize(path13);
4201
- return expand2 ? path13.replace(/^~(?=\/|\\|$)/, homePath) : path13.replace(new RegExp("^" + escapePattern(homePath) + "(?=\\/|\\\\|$)", IS_WIN ? "i" : ""), "~");
4202
- }
4203
- function replacePlaceholder(text, generator) {
4204
- var PTN_INNER = "(?:\\(([\\s\\S]*?)\\))?(\\w+|.-.)(?:\\(([\\s\\S]*?)\\))?", rePlaceholder = new RegExp("(\\$)?(\\$<" + PTN_INNER + ">)", "g"), rePlaceholderCompat = new RegExp("(\\$)?(\\$\\{" + PTN_INNER + "\\})", "g");
4205
- function getPlaceholderText(s, escape2, placeholder, pre, param, post) {
4206
- var text2;
4207
- return escape2 || typeof (text2 = generator(param)) !== "string" ? placeholder : text2 ? (pre || "") + text2 + (post || "") : "";
4208
- }
4209
- return text.replace(rePlaceholder, getPlaceholderText).replace(rePlaceholderCompat, getPlaceholderText);
4210
- }
4211
- function array2charlist(array, caseSensitive, collectSymbols) {
4212
- var group = [], groupClass = -1, charCode = 0, symbols = "", values, suppressed;
4213
- function addGroup(groups, group2) {
4214
- if (group2.length > 3) {
4215
- groups.push(group2[0] + "..." + group2[group2.length - 1]);
4216
- suppressed = true;
4217
- } else if (group2.length) {
4218
- groups = groups.concat(group2);
4219
- }
4220
- return groups;
4221
- }
4222
- values = array.reduce(function(chars, value) {
4223
- return chars.concat((value + "").split(""));
4224
- }, []).reduce(function(groups, curChar) {
4225
- var curGroupClass, curCharCode;
4226
- if (!caseSensitive) {
4227
- curChar = curChar.toLowerCase();
4228
- }
4229
- curGroupClass = /^\d$/.test(curChar) ? 1 : /^[A-Z]$/.test(curChar) ? 2 : /^[a-z]$/.test(curChar) ? 3 : 0;
4230
- if (collectSymbols && curGroupClass === 0) {
4231
- symbols += curChar;
4232
- } else {
4233
- curCharCode = curChar.charCodeAt(0);
4234
- if (curGroupClass && curGroupClass === groupClass && curCharCode === charCode + 1) {
4235
- group.push(curChar);
4236
- } else {
4237
- groups = addGroup(groups, group);
4238
- group = [curChar];
4239
- groupClass = curGroupClass;
4240
- }
4241
- charCode = curCharCode;
4242
- }
4243
- return groups;
4244
- }, []);
4245
- values = addGroup(values, group);
4246
- if (symbols) {
4247
- values.push(symbols);
4248
- suppressed = true;
4249
- }
4250
- return { values, suppressed };
4251
- }
4252
- function joinChunks(chunks, suppressed) {
4253
- return chunks.join(chunks.length > 2 ? ", " : suppressed ? " / " : "/");
4254
- }
4255
- function getPhContent(param, options) {
4256
- var resCharlist = {}, text, values, arg;
4257
- if (options.phContent) {
4258
- text = options.phContent(param, options);
4259
- }
4260
- if (typeof text !== "string") {
4261
- switch (param) {
4262
- case "hideEchoBack":
4263
- case "mask":
4264
- case "defaultInput":
4265
- case "caseSensitive":
4266
- case "keepWhitespace":
4267
- case "encoding":
4268
- case "bufferSize":
4269
- case "history":
4270
- case "cd":
4271
- text = !options.hasOwnProperty(param) ? "" : typeof options[param] === "boolean" ? options[param] ? "on" : "off" : options[param] + "";
4272
- break;
4273
- // case 'prompt':
4274
- // case 'query':
4275
- // case 'display':
4276
- // text = options.hasOwnProperty('displaySrc') ? options.displaySrc + '' : '';
4277
- // break;
4278
- case "limit":
4279
- case "trueValue":
4280
- case "falseValue":
4281
- values = options[options.hasOwnProperty(param + "Src") ? param + "Src" : param];
4282
- if (options.keyIn) {
4283
- resCharlist = array2charlist(values, options.caseSensitive);
4284
- values = resCharlist.values;
4285
- } else {
4286
- values = values.filter(function(value) {
4287
- var type = typeof value;
4288
- return type === "string" || type === "number";
4289
- });
4290
- }
4291
- text = joinChunks(values, resCharlist.suppressed);
4292
- break;
4293
- case "limitCount":
4294
- case "limitCountNotZero":
4295
- text = options[options.hasOwnProperty("limitSrc") ? "limitSrc" : "limit"].length;
4296
- text = text || param !== "limitCountNotZero" ? text + "" : "";
4297
- break;
4298
- case "lastInput":
4299
- text = lastInput;
4300
- break;
4301
- case "cwd":
4302
- case "CWD":
4303
- case "cwdHome":
4304
- text = process.cwd();
4305
- if (param === "CWD") {
4306
- text = pathUtil.basename(text);
4307
- } else if (param === "cwdHome") {
4308
- text = replaceHomePath(text);
4309
- }
4310
- break;
4311
- case "date":
4312
- case "time":
4313
- case "localeDate":
4314
- case "localeTime":
4315
- text = (/* @__PURE__ */ new Date())["to" + param.replace(/^./, function(str) {
4316
- return str.toUpperCase();
4317
- }) + "String"]();
4318
- break;
4319
- default:
4320
- if (typeof (arg = (param.match(/^history_m(\d+)$/) || [])[1]) === "string") {
4321
- text = inputHistory[inputHistory.length - arg] || "";
4322
- }
4323
- }
4324
- }
4325
- return text;
4326
- }
4327
- function getPhCharlist(param) {
4328
- var matches = /^(.)-(.)$/.exec(param), text = "", from, to, code, step;
4329
- if (!matches) {
4330
- return null;
4331
- }
4332
- from = matches[1].charCodeAt(0);
4333
- to = matches[2].charCodeAt(0);
4334
- step = from < to ? 1 : -1;
4335
- for (code = from; code !== to + step; code += step) {
4336
- text += String.fromCharCode(code);
4337
- }
4338
- return text;
4339
- }
4340
- function parseCl(cl) {
4341
- var reToken = new RegExp(/(\s*)(?:("|')(.*?)(?:\2|$)|(\S+))/g), taken = "", args = [], matches, part;
4342
- cl = cl.trim();
4343
- while (matches = reToken.exec(cl)) {
4344
- part = matches[3] || matches[4] || "";
4345
- if (matches[1]) {
4346
- args.push(taken);
4347
- taken = "";
4348
- }
4349
- taken += part;
4350
- }
4351
- if (taken) {
4352
- args.push(taken);
4353
- }
4354
- return args;
4355
- }
4356
- function toBool(res, options) {
4357
- return options.trueValue.length && isMatched(res, options.trueValue, options.caseSensitive) ? true : options.falseValue.length && isMatched(res, options.falseValue, options.caseSensitive) ? false : res;
4358
- }
4359
- function getValidLine(options) {
4360
- var res, forceNext, limitMessage, matches, histInput, args, resCheck;
4361
- function _getPhContent(param) {
4362
- return getPhContent(param, options);
4363
- }
4364
- function addDisplay(text) {
4365
- options.display += (/[^\r\n]$/.test(options.display) ? "\n" : "") + text;
4366
- }
4367
- options.limitSrc = options.limit;
4368
- options.displaySrc = options.display;
4369
- options.limit = "";
4370
- options.display = replacePlaceholder(options.display + "", _getPhContent);
4371
- while (true) {
4372
- res = _readlineSync(options);
4373
- forceNext = false;
4374
- limitMessage = "";
4375
- if (options.defaultInput && !res) {
4376
- res = options.defaultInput;
4377
- }
4378
- if (options.history) {
4379
- if (matches = /^\s*!(?:!|-1)(:p)?\s*$/.exec(res)) {
4380
- histInput = inputHistory[0] || "";
4381
- if (matches[1]) {
4382
- forceNext = true;
4383
- } else {
4384
- res = histInput;
4385
- }
4386
- addDisplay(histInput + "\n");
4387
- if (!forceNext) {
4388
- options.displayOnly = true;
4389
- _readlineSync(options);
4390
- options.displayOnly = false;
4391
- }
4392
- } else if (res && res !== inputHistory[inputHistory.length - 1]) {
4393
- inputHistory = [res];
4394
- }
4395
- }
4396
- if (!forceNext && options.cd && res) {
4397
- args = parseCl(res);
4398
- switch (args[0].toLowerCase()) {
4399
- case "cd":
4400
- if (args[1]) {
4401
- try {
4402
- process.chdir(replaceHomePath(args[1], true));
4403
- } catch (e) {
4404
- addDisplay(e + "");
4405
- }
4406
- }
4407
- forceNext = true;
4408
- break;
4409
- case "pwd":
4410
- addDisplay(process.cwd());
4411
- forceNext = true;
4412
- break;
4413
- }
4414
- }
4415
- if (!forceNext && options.preCheck) {
4416
- resCheck = options.preCheck(res, options);
4417
- res = resCheck.res;
4418
- if (resCheck.forceNext) {
4419
- forceNext = true;
4420
- }
4421
- }
4422
- if (!forceNext) {
4423
- if (!options.limitSrc.length || isMatched(res, options.limitSrc, options.caseSensitive)) {
4424
- break;
4425
- }
4426
- if (options.limitMessage) {
4427
- limitMessage = replacePlaceholder(options.limitMessage, _getPhContent);
4428
- }
4429
- }
4430
- addDisplay((limitMessage ? limitMessage + "\n" : "") + replacePlaceholder(options.displaySrc + "", _getPhContent));
4431
- }
4432
- return toBool(res, options);
4433
- }
4434
- exports2._DBG_set_useExt = function(val) {
4435
- _DBG_useExt = val;
4436
- };
4437
- exports2._DBG_set_checkOptions = function(val) {
4438
- _DBG_checkOptions = val;
4439
- };
4440
- exports2._DBG_set_checkMethod = function(val) {
4441
- _DBG_checkMethod = val;
4442
- };
4443
- exports2._DBG_clearHistory = function() {
4444
- lastInput = "";
4445
- inputHistory = [];
4446
- };
4447
- exports2.setDefaultOptions = function(options) {
4448
- defaultOptions = margeOptions(true, options);
4449
- return margeOptions(true);
4450
- };
4451
- exports2.question = function(query, options) {
4452
- return getValidLine(margeOptions(margeOptions(true, options), {
4453
- display: query
4454
- }));
4455
- };
4456
- exports2.prompt = function(options) {
4457
- var readOptions = margeOptions(true, options);
4458
- readOptions.display = readOptions.prompt;
4459
- return getValidLine(readOptions);
4460
- };
4461
- exports2.keyIn = function(query, options) {
4462
- var readOptions = margeOptions(margeOptions(true, options), {
4463
- display: query,
4464
- keyIn: true,
4465
- keepWhitespace: true
4466
- });
4467
- readOptions.limitSrc = readOptions.limit.filter(function(value) {
4468
- var type = typeof value;
4469
- return type === "string" || type === "number";
4470
- }).map(function(text) {
4471
- return replacePlaceholder(text + "", getPhCharlist);
4472
- });
4473
- readOptions.limit = escapePattern(readOptions.limitSrc.join(""));
4474
- ["trueValue", "falseValue"].forEach(function(optionName) {
4475
- readOptions[optionName] = readOptions[optionName].reduce(function(comps, comp) {
4476
- var type = typeof comp;
4477
- if (type === "string" || type === "number") {
4478
- comps = comps.concat((comp + "").split(""));
4479
- } else {
4480
- comps.push(comp);
4481
- }
4482
- return comps;
4483
- }, []);
4484
- });
4485
- readOptions.display = replacePlaceholder(
4486
- readOptions.display + "",
4487
- function(param) {
4488
- return getPhContent(param, readOptions);
4489
- }
4490
- );
4491
- return toBool(_readlineSync(readOptions), readOptions);
4492
- };
4493
- exports2.questionEMail = function(query, options) {
4494
- if (query == null) {
4495
- query = "Input e-mail address: ";
4496
- }
4497
- return exports2.question(query, margeOptions({
4498
- // -------- default
4499
- hideEchoBack: false,
4500
- // http://www.w3.org/TR/html5/forms.html#valid-e-mail-address
4501
- limit: /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,
4502
- limitMessage: "Input valid e-mail address, please.",
4503
- trueValue: null,
4504
- falseValue: null
4505
- }, options, {
4506
- // -------- forced
4507
- keepWhitespace: false,
4508
- cd: false
4509
- }));
4510
- };
4511
- exports2.questionNewPassword = function(query, options) {
4512
- var resCharlist, min, max, readOptions = margeOptions({
4513
- // -------- default
4514
- hideEchoBack: true,
4515
- mask: "*",
4516
- limitMessage: "It can include: $<charlist>\nAnd the length must be: $<length>",
4517
- trueValue: null,
4518
- falseValue: null,
4519
- caseSensitive: true
4520
- }, options, {
4521
- // -------- forced
4522
- history: false,
4523
- cd: false,
4524
- // limit (by charlist etc.),
4525
- phContent: function(param) {
4526
- return param === "charlist" ? resCharlist.text : param === "length" ? min + "..." + max : null;
4527
- }
4528
- }), charlist, confirmMessage, unmatchMessage, limit, limitMessage, res1, res2;
4529
- options = options || {};
4530
- charlist = replacePlaceholder(
4531
- options.charlist ? options.charlist + "" : "$<!-~>",
4532
- getPhCharlist
4533
- );
4534
- if (isNaN(min = parseInt(options.min, 10)) || typeof min !== "number") {
4535
- min = 12;
4536
- }
4537
- if (isNaN(max = parseInt(options.max, 10)) || typeof max !== "number") {
4538
- max = 24;
4539
- }
4540
- limit = new RegExp("^[" + escapePattern(charlist) + "]{" + min + "," + max + "}$");
4541
- resCharlist = array2charlist([charlist], readOptions.caseSensitive, true);
4542
- resCharlist.text = joinChunks(resCharlist.values, resCharlist.suppressed);
4543
- confirmMessage = options.confirmMessage != null ? options.confirmMessage : "Reinput a same one to confirm it: ";
4544
- unmatchMessage = options.unmatchMessage != null ? options.unmatchMessage : "It differs from first one. Hit only the Enter key if you want to retry from first one.";
4545
- if (query == null) {
4546
- query = "Input new password: ";
4547
- }
4548
- limitMessage = readOptions.limitMessage;
4549
- while (!res2) {
4550
- readOptions.limit = limit;
4551
- readOptions.limitMessage = limitMessage;
4552
- res1 = exports2.question(query, readOptions);
4553
- readOptions.limit = [res1, ""];
4554
- readOptions.limitMessage = unmatchMessage;
4555
- res2 = exports2.question(confirmMessage, readOptions);
4556
- }
4557
- return res1;
4558
- };
4559
- function _questionNum(query, options, parser) {
4560
- var validValue;
4561
- function getValidValue(value) {
4562
- validValue = parser(value);
4563
- return !isNaN(validValue) && typeof validValue === "number";
4564
- }
4565
- exports2.question(query, margeOptions({
4566
- // -------- default
4567
- limitMessage: "Input valid number, please."
4568
- }, options, {
4569
- // -------- forced
4570
- limit: getValidValue,
4571
- cd: false
4572
- // trueValue, falseValue, caseSensitive, keepWhitespace don't work.
4573
- }));
4574
- return validValue;
4575
- }
4576
- exports2.questionInt = function(query, options) {
4577
- return _questionNum(query, options, function(value) {
4578
- return parseInt(value, 10);
4579
- });
4580
- };
4581
- exports2.questionFloat = function(query, options) {
4582
- return _questionNum(query, options, parseFloat);
4583
- };
4584
- exports2.questionPath = function(query, options) {
4585
- var error = "", validPath, readOptions = margeOptions({
4586
- // -------- default
4587
- hideEchoBack: false,
4588
- limitMessage: "$<error(\n)>Input valid path, please.$<( Min:)min>$<( Max:)max>",
4589
- history: true,
4590
- cd: true
4591
- }, options, {
4592
- // -------- forced
4593
- keepWhitespace: false,
4594
- limit: function(value) {
4595
- var exists, stat, res;
4596
- value = replaceHomePath(value, true);
4597
- error = "";
4598
- function mkdirParents(dirPath) {
4599
- dirPath.split(/\/|\\/).reduce(function(parents, dir) {
4600
- var path13 = pathUtil.resolve(parents += dir + pathUtil.sep);
4601
- if (!fs10.existsSync(path13)) {
4602
- fs10.mkdirSync(path13);
4603
- } else if (!fs10.statSync(path13).isDirectory()) {
4604
- throw new Error("Non directory already exists: " + path13);
4605
- }
4606
- return parents;
4607
- }, "");
4608
- }
4609
- try {
4610
- exists = fs10.existsSync(value);
4611
- validPath = exists ? fs10.realpathSync(value) : pathUtil.resolve(value);
4612
- if (!options.hasOwnProperty("exists") && !exists || typeof options.exists === "boolean" && options.exists !== exists) {
4613
- error = (exists ? "Already exists" : "No such file or directory") + ": " + validPath;
4614
- return false;
4615
- }
4616
- if (!exists && options.create) {
4617
- if (options.isDirectory) {
4618
- mkdirParents(validPath);
4619
- } else {
4620
- mkdirParents(pathUtil.dirname(validPath));
4621
- fs10.closeSync(fs10.openSync(validPath, "w"));
4622
- }
4623
- validPath = fs10.realpathSync(validPath);
4624
- }
4625
- if (exists && (options.min || options.max || options.isFile || options.isDirectory)) {
4626
- stat = fs10.statSync(validPath);
4627
- if (options.isFile && !stat.isFile()) {
4628
- error = "Not file: " + validPath;
4629
- return false;
4630
- } else if (options.isDirectory && !stat.isDirectory()) {
4631
- error = "Not directory: " + validPath;
4632
- return false;
4633
- } else if (options.min && stat.size < +options.min || options.max && stat.size > +options.max) {
4634
- error = "Size " + stat.size + " is out of range: " + validPath;
4635
- return false;
4636
- }
4637
- }
4638
- if (typeof options.validate === "function" && (res = options.validate(validPath)) !== true) {
4639
- if (typeof res === "string") {
4640
- error = res;
4641
- }
4642
- return false;
4643
- }
4644
- } catch (e) {
4645
- error = e + "";
4646
- return false;
4647
- }
4648
- return true;
4649
- },
4650
- // trueValue, falseValue, caseSensitive don't work.
4651
- phContent: function(param) {
4652
- return param === "error" ? error : param !== "min" && param !== "max" ? null : options.hasOwnProperty(param) ? options[param] + "" : "";
4653
- }
4654
- });
4655
- options = options || {};
4656
- if (query == null) {
4657
- query = 'Input path (you can "cd" and "pwd"): ';
4658
- }
4659
- exports2.question(query, readOptions);
4660
- return validPath;
4661
- };
4662
- function getClHandler(commandHandler, options) {
4663
- var clHandler = {}, hIndex = {};
4664
- if (typeof commandHandler === "object") {
4665
- Object.keys(commandHandler).forEach(function(cmd) {
4666
- if (typeof commandHandler[cmd] === "function") {
4667
- hIndex[options.caseSensitive ? cmd : cmd.toLowerCase()] = commandHandler[cmd];
4668
- }
4669
- });
4670
- clHandler.preCheck = function(res) {
4671
- var cmdKey;
4672
- clHandler.args = parseCl(res);
4673
- cmdKey = clHandler.args[0] || "";
4674
- if (!options.caseSensitive) {
4675
- cmdKey = cmdKey.toLowerCase();
4676
- }
4677
- clHandler.hRes = cmdKey !== "_" && hIndex.hasOwnProperty(cmdKey) ? hIndex[cmdKey].apply(res, clHandler.args.slice(1)) : hIndex.hasOwnProperty("_") ? hIndex._.apply(res, clHandler.args) : null;
4678
- return { res, forceNext: false };
4679
- };
4680
- if (!hIndex.hasOwnProperty("_")) {
4681
- clHandler.limit = function() {
4682
- var cmdKey = clHandler.args[0] || "";
4683
- if (!options.caseSensitive) {
4684
- cmdKey = cmdKey.toLowerCase();
4685
- }
4686
- return hIndex.hasOwnProperty(cmdKey);
4687
- };
4688
- }
4689
- } else {
4690
- clHandler.preCheck = function(res) {
4691
- clHandler.args = parseCl(res);
4692
- clHandler.hRes = typeof commandHandler === "function" ? commandHandler.apply(res, clHandler.args) : true;
4693
- return { res, forceNext: false };
4694
- };
4695
- }
4696
- return clHandler;
4697
- }
4698
- exports2.promptCL = function(commandHandler, options) {
4699
- var readOptions = margeOptions({
4700
- // -------- default
4701
- hideEchoBack: false,
4702
- limitMessage: "Requested command is not available.",
4703
- caseSensitive: false,
4704
- history: true
4705
- }, options), clHandler = getClHandler(commandHandler, readOptions);
4706
- readOptions.limit = clHandler.limit;
4707
- readOptions.preCheck = clHandler.preCheck;
4708
- exports2.prompt(readOptions);
4709
- return clHandler.args;
4710
- };
4711
- exports2.promptLoop = function(inputHandler, options) {
4712
- var readOptions = margeOptions({
4713
- // -------- default
4714
- hideEchoBack: false,
4715
- trueValue: null,
4716
- falseValue: null,
4717
- caseSensitive: false,
4718
- history: true
4719
- }, options);
4720
- while (true) {
4721
- if (inputHandler(exports2.prompt(readOptions))) {
4722
- break;
4723
- }
4724
- }
4725
- };
4726
- exports2.promptCLLoop = function(commandHandler, options) {
4727
- var readOptions = margeOptions({
4728
- // -------- default
4729
- hideEchoBack: false,
4730
- limitMessage: "Requested command is not available.",
4731
- caseSensitive: false,
4732
- history: true
4733
- }, options), clHandler = getClHandler(commandHandler, readOptions);
4734
- readOptions.limit = clHandler.limit;
4735
- readOptions.preCheck = clHandler.preCheck;
4736
- while (true) {
4737
- exports2.prompt(readOptions);
4738
- if (clHandler.hRes) {
4739
- break;
4740
- }
4741
- }
4742
- };
4743
- exports2.promptSimShell = function(options) {
4744
- return exports2.prompt(margeOptions({
4745
- // -------- default
4746
- hideEchoBack: false,
4747
- history: true
4748
- }, options, {
4749
- // -------- forced
4750
- prompt: (function() {
4751
- return IS_WIN ? "$<cwd>>" : (
4752
- // 'user@host:cwd$ '
4753
- (process.env.USER || "") + (process.env.HOSTNAME ? "@" + process.env.HOSTNAME.replace(/\..*$/, "") : "") + ":$<cwdHome>$ "
4754
- );
4755
- })()
4756
- }));
4757
- };
4758
- function _keyInYN(query, options, limit) {
4759
- var res;
4760
- if (query == null) {
4761
- query = "Are you sure? ";
4762
- }
4763
- if ((!options || options.guide !== false) && (query += "")) {
4764
- query = query.replace(/\s*:?\s*$/, "") + " [y/n]: ";
4765
- }
4766
- res = exports2.keyIn(query, margeOptions(options, {
4767
- // -------- forced
4768
- hideEchoBack: false,
4769
- limit,
4770
- trueValue: "y",
4771
- falseValue: "n",
4772
- caseSensitive: false
4773
- // mask doesn't work.
4774
- }));
4775
- return typeof res === "boolean" ? res : "";
4776
- }
4777
- exports2.keyInYN = function(query, options) {
4778
- return _keyInYN(query, options);
4779
- };
4780
- exports2.keyInYNStrict = function(query, options) {
4781
- return _keyInYN(query, options, "yn");
4782
- };
4783
- exports2.keyInPause = function(query, options) {
4784
- if (query == null) {
4785
- query = "Continue...";
4786
- }
4787
- if ((!options || options.guide !== false) && (query += "")) {
4788
- query = query.replace(/\s+$/, "") + " (Hit any key)";
4789
- }
4790
- exports2.keyIn(query, margeOptions({
4791
- // -------- default
4792
- limit: null
4793
- }, options, {
4794
- // -------- forced
4795
- hideEchoBack: true,
4796
- mask: ""
4797
- }));
4798
- };
4799
- exports2.keyInSelect = function(items, query, options) {
4800
- var readOptions = margeOptions({
4801
- // -------- default
4802
- hideEchoBack: false
4803
- }, options, {
4804
- // -------- forced
4805
- trueValue: null,
4806
- falseValue: null,
4807
- caseSensitive: false,
4808
- // limit (by items),
4809
- phContent: function(param) {
4810
- return param === "itemsCount" ? items.length + "" : param === "firstItem" ? (items[0] + "").trim() : param === "lastItem" ? (items[items.length - 1] + "").trim() : null;
4811
- }
4812
- }), keylist = "", key2i = {}, charCode = 49, display = "\n";
4813
- if (!Array.isArray(items) || !items.length || items.length > 35) {
4814
- throw "`items` must be Array (max length: 35).";
4815
- }
4816
- items.forEach(function(item, i) {
4817
- var key = String.fromCharCode(charCode);
4818
- keylist += key;
4819
- key2i[key] = i;
4820
- display += "[" + key + "] " + (item + "").trim() + "\n";
4821
- charCode = charCode === 57 ? 97 : charCode + 1;
4822
- });
4823
- if (!options || options.cancel !== false) {
4824
- keylist += "0";
4825
- key2i["0"] = -1;
4826
- display += "[0] " + (options && options.cancel != null && typeof options.cancel !== "boolean" ? (options.cancel + "").trim() : "CANCEL") + "\n";
4827
- }
4828
- readOptions.limit = keylist;
4829
- display += "\n";
4830
- if (query == null) {
4831
- query = "Choose one from list: ";
4832
- }
4833
- if (query += "") {
4834
- if (!options || options.guide !== false) {
4835
- query = query.replace(/\s*:?\s*$/, "") + " [$<limit>]: ";
4836
- }
4837
- display += query;
4838
- }
4839
- return key2i[exports2.keyIn(display, readOptions).toLowerCase()];
4840
- };
4841
- exports2.getRawInput = function() {
4842
- return rawInput;
4843
- };
4844
- function _setOption(optionName, args) {
4845
- var options;
4846
- if (args.length) {
4847
- options = {};
4848
- options[optionName] = args[0];
4849
- }
4850
- return exports2.setDefaultOptions(options)[optionName];
4851
- }
4852
- exports2.setPrint = function() {
4853
- return _setOption("print", arguments);
4854
- };
4855
- exports2.setPrompt = function() {
4856
- return _setOption("prompt", arguments);
4857
- };
4858
- exports2.setEncoding = function() {
4859
- return _setOption("encoding", arguments);
4860
- };
4861
- exports2.setMask = function() {
4862
- return _setOption("mask", arguments);
4863
- };
4864
- exports2.setBufferSize = function() {
4865
- return _setOption("bufferSize", arguments);
4866
- };
4867
- }
4868
- });
4869
-
4870
3670
  // ../../node_modules/@sindresorhus/merge-streams/index.js
4871
3671
  function mergeStreams(streams) {
4872
3672
  if (!Array.isArray(streams)) {
@@ -20473,7 +19273,6 @@ var glob = Object.assign(glob_, {
20473
19273
  glob.glob = glob;
20474
19274
 
20475
19275
  // src/commands/check-header.ts
20476
- var readline = __toESM(require_readline_sync());
20477
19276
  var path5 = __toESM(require("path"));
20478
19277
 
20479
19278
  // src/util/file-util.ts
@@ -21010,7 +19809,9 @@ function validate(rootDir, files, options) {
21010
19809
  }
21011
19810
  });
21012
19811
  results.sort((a, b) => a.file.localeCompare(b.file));
21013
- process.stdout.clearLine(0);
19812
+ if (process.stdout.isTTY) {
19813
+ process.stdout.clearLine(0);
19814
+ }
21014
19815
  return results;
21015
19816
  }
21016
19817
  function validateEndYear(result) {
@@ -21023,13 +19824,13 @@ function validateEndYear(result) {
21023
19824
  }
21024
19825
  }
21025
19826
  function printFileProgress(currentFileCount, maxFileCount, message, clear = true) {
21026
- if (clear) {
19827
+ if (clear && process.stdout.isTTY) {
21027
19828
  process.stdout.clearLine(0);
21028
19829
  process.stdout.cursorTo(0);
21029
- }
21030
- process.stdout.write(`[${currentFileCount} of ${maxFileCount}] ${message}`);
21031
- if (!clear) {
21032
- process.stdout.write("\n");
19830
+ process.stdout.write(`[${currentFileCount} of ${maxFileCount}] ${message}`);
19831
+ } else {
19832
+ process.stdout.write(`[${currentFileCount} of ${maxFileCount}] ${message}
19833
+ `);
21033
19834
  }
21034
19835
  }
21035
19836
  function handleValidationResults(rootDir, results, options) {
@@ -21044,11 +19845,14 @@ function handleValidationResults(rootDir, results, options) {
21044
19845
  if (options.json) {
21045
19846
  fs4.writeFileSync(path5.join(rootDir, "headerCheck.json"), JSON.stringify(results, void 0, 2));
21046
19847
  }
21047
- if (violations.length > 0 && (options.autoFix || readline.keyInYN("Do you want to automatically fix copyright year range violations?"))) {
19848
+ if (violations.length > 0 && options.autoFix) {
21048
19849
  const toFix = violations.filter((violation) => isDateValidationResult(violation));
21049
19850
  fixViolations(rootDir, toFix, options);
21050
19851
  }
21051
19852
  LOGGER.info("Check completed");
19853
+ if (violations.length > 0 && !options.autoFix) {
19854
+ process.exit(1);
19855
+ }
21052
19856
  }
21053
19857
  function toPrintMessage(result) {
21054
19858
  const error = "\x1B[31m";
@@ -21074,7 +19878,7 @@ function fixViolations(rootDir, violations, options) {
21074
19878
  replaceInFile(violation.file, RegExp("Copyright \\([cC]\\) " + currentRange), `Copyright (c) ${fixedRange}`);
21075
19879
  });
21076
19880
  LOGGER.newLine();
21077
- if (options.commit && (options.autoFix || readline.keyInYN("Do you want to create a commit for the fixed files?"))) {
19881
+ if (options.commit && options.autoFix) {
21078
19882
  LOGGER.newLine();
21079
19883
  const files = violations.map((violation) => violation.file).join(" ");
21080
19884
  exec(`git add ${files}`);