nuxt-gin-tools 0.2.2 → 0.2.3
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/package.json +1 -1
- package/src/dev-go.js +18 -2
package/package.json
CHANGED
package/src/dev-go.js
CHANGED
|
@@ -19,11 +19,13 @@ const chokidar_1 = __importDefault(require("chokidar"));
|
|
|
19
19
|
const chalk_1 = __importDefault(require("chalk"));
|
|
20
20
|
const fs_extra_1 = require("fs-extra");
|
|
21
21
|
const os_1 = __importDefault(require("os"));
|
|
22
|
+
const readline_1 = require("readline");
|
|
22
23
|
const path_1 = require("path");
|
|
23
24
|
const cwd = process.cwd();
|
|
24
25
|
const RESTART_DEBOUNCE_MS = 150;
|
|
25
26
|
const SHUTDOWN_TIMEOUT_MS = 2000;
|
|
26
27
|
const LOG_TAG = "go-watch";
|
|
28
|
+
const GO_OUTPUT_TAG = chalk_1.default.blue("[go]");
|
|
27
29
|
const serverConfigPath = (0, path_1.join)(cwd, "server.config.json");
|
|
28
30
|
const ginPort = getGinPort();
|
|
29
31
|
function getGinPort() {
|
|
@@ -260,15 +262,29 @@ function quote(arg) {
|
|
|
260
262
|
}
|
|
261
263
|
return arg;
|
|
262
264
|
}
|
|
265
|
+
function forwardWithGoTag(input, output) {
|
|
266
|
+
if (!input) {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
const rl = (0, readline_1.createInterface)({ input });
|
|
270
|
+
rl.on("line", (line) => {
|
|
271
|
+
output.write(`${GO_OUTPUT_TAG} ${line}\n`);
|
|
272
|
+
});
|
|
273
|
+
}
|
|
263
274
|
function runGoProcess() {
|
|
275
|
+
var _a, _b, _c;
|
|
264
276
|
const command = `go run ${quote("main.go")}`;
|
|
265
277
|
killGinPortIfNeeded();
|
|
266
278
|
console.log(chalk_1.default.green(`[${LOG_TAG}] start: ${command}`));
|
|
267
|
-
|
|
279
|
+
const proc = (0, child_process_1.spawn)(command, {
|
|
268
280
|
cwd,
|
|
269
281
|
shell: true,
|
|
270
|
-
|
|
282
|
+
env: Object.assign(Object.assign({}, process.env), { FORCE_COLOR: (_a = process.env.FORCE_COLOR) !== null && _a !== void 0 ? _a : "1", CLICOLOR: (_b = process.env.CLICOLOR) !== null && _b !== void 0 ? _b : "1", CLICOLOR_FORCE: (_c = process.env.CLICOLOR_FORCE) !== null && _c !== void 0 ? _c : "1" }),
|
|
283
|
+
stdio: ["inherit", "pipe", "pipe"],
|
|
271
284
|
});
|
|
285
|
+
forwardWithGoTag(proc.stdout, process.stdout);
|
|
286
|
+
forwardWithGoTag(proc.stderr, process.stderr);
|
|
287
|
+
return proc;
|
|
272
288
|
}
|
|
273
289
|
function stopGoProcess(proc) {
|
|
274
290
|
return __awaiter(this, void 0, void 0, function* () {
|