@danielx/civet 0.5.37 → 0.5.39

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/civet CHANGED
@@ -110,7 +110,7 @@ parseArgs = function(args = process.argv.slice(2)) {
110
110
  endOfArgs(++i);
111
111
  break;
112
112
  default:
113
- if (arg.startsWith("-")) {
113
+ if (arg.startsWith("-") && arg !== "-") {
114
114
  throw new Error(`Invalid command-line argument ${arg}`);
115
115
  }
116
116
  if (options.run) {
@@ -124,7 +124,7 @@ parseArgs = function(args = process.argv.slice(2)) {
124
124
  return { filenames, scriptArgs, options };
125
125
  };
126
126
  readFiles = async function* (filenames, options) {
127
- var content, error, filename, k, len, lines, results, rl, stdin;
127
+ var chunk, content, error, filename, k, len, lines, results, rl, stdin;
128
128
  results = [];
129
129
  for (k = 0, len = filenames.length; k < len; k++) {
130
130
  filename = filenames[k];
@@ -137,21 +137,31 @@ readFiles = async function* (filenames, options) {
137
137
  filename = await fs.realpath("/dev/stdin");
138
138
  } catch (error1) {
139
139
  }
140
- }
141
- if (filename === "<stdin>") {
142
- lines = [];
143
- rl = require("readline").createInterface(process.stdin, process.stdout);
144
- rl.on("line", function(buffer) {
145
- return lines.push(buffer + "\n");
146
- });
147
- content = await new Promise(function(resolve, reject) {
148
- rl.on("SIGINT", function() {
149
- return reject("^C");
140
+ if (process.stdin.isTTY) {
141
+ lines = [];
142
+ rl = require("readline").createInterface(process.stdin, process.stdout);
143
+ rl.on("line", function(buffer) {
144
+ return lines.push(buffer + "\n");
150
145
  });
151
- return rl.on("close", function() {
152
- return resolve(lines.join(""));
146
+ content = await new Promise(function(resolve, reject) {
147
+ rl.on("SIGINT", function() {
148
+ return reject("^C");
149
+ });
150
+ return rl.on("close", function() {
151
+ return resolve(lines.join(""));
152
+ });
153
153
  });
154
- });
154
+ } else {
155
+ content = (await async function() {
156
+ var ref, results1;
157
+ ref = process.stdin;
158
+ results1 = [];
159
+ for await (chunk of ref) {
160
+ results1.push(chunk);
161
+ }
162
+ return results1;
163
+ }()).join("");
164
+ }
155
165
  } else {
156
166
  content = await fs.readFile(filename, { encoding });
157
167
  }