Skip to content

Instantly share code, notes, and snippets.

@emeraldsanto
Created August 4, 2020 02:07
Show Gist options
  • Save emeraldsanto/ffc6e2176d035166792bcc1fc90d6904 to your computer and use it in GitHub Desktop.
Save emeraldsanto/ffc6e2176d035166792bcc1fc90d6904 to your computer and use it in GitHub Desktop.
Script to be run via NPM commands to generate the correct `env.json` file based on the provided environment name and the existing environment files
#!/bin/node
/**
* This scripts will create a `env.json` file at the root of the project
* with the content matching that of the desired environment file, as defined in `/src/env/`
*
* @example
* npx ts-node src/scripts/set-environment.ts production
*/
import fs from "fs";
const environment = process.argv[2];
const environmentFile = require(`../env/${environment}.json`);
fs.writeFileSync(
"env.json",
JSON.stringify(environmentFile, null, 4)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment