UNPKG

foalts2-cli

Version:

CLI tool for FoalTS

30 lines (29 loc) 1.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.connectReact = void 0; const path_1 = require("path"); const safe_1 = require("colors/safe"); const file_system_1 = require("../../file-system"); function connectReact(path) { const fs = new file_system_1.FileSystem(); if (!fs.exists(path)) { if (process.env.P1Z7kEbSUUPMxF8GqPwD8Gx_FOAL_CLI_TEST !== 'true') { console.log(safe_1.red(` The directory ${path} does not exist.`)); } return; } if (!fs.exists(path_1.join(path, 'package.json'))) { if (process.env.P1Z7kEbSUUPMxF8GqPwD8Gx_FOAL_CLI_TEST !== 'true') { console.log(safe_1.red(` The directory ${path} is not a React project (missing package.json).`)); } return; } fs .cd(path) .modify('package.json', content => { const pkg = JSON.parse(content); pkg.proxy = 'http://localhost:3001'; return JSON.stringify(pkg, null, 2); }); } exports.connectReact = connectReact;