How to use the envfile.parseFileSync function in envfile

To help you get started, we’ve selected a few envfile examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hernanjkd / Resume-Builder / deploy-to-github.js View on Github external
Console.help(`Check your remote by doing:
$ git remote get-url origin

Add your remote by doing:
$ git remote add origin 
`);
return;
}
Console.info("The remote was found successfully, starting the deploy from here: "+origin);

//get the repository project name
const repository = gh(origin);

// update the env file
const envPath = './.env';
const env = envfile.parseFileSync(envPath);
env['BASENAME'] = `/${repository["name"]}/`;
Console.info("Updating the .env file with the basename "+repository["name"]);
fs.writeFileSync(envPath, envfile.stringifySync(env));

const compiler = webpack(require(path.resolve(__dirname, 'webpack.prod.js')));
compiler.run((err, stats) => {
    if (err || stats.hasErrors()) {
      console.log(stats.toString({
        colors: true
      }));
      Console.error("There was an error compiling, review above");
      return;
    }
    Console.success("Your code compiled successfully, proceding to deploy...");
    ghpages.publish('public', function(err) {
        if(err){
github ArkEcosystem / core / packages / core-container / src / environment.ts View on Github external
private exportVariables() {
        process.env.CORE_TOKEN = this.variables.token;

        // Don't pollute the test environment!
        if (process.env.NODE_ENV === "test") {
            return;
        }

        const envPath = expandHomeDir(`${process.env.CORE_PATH_CONFIG}/.env`);

        if (existsSync(envPath)) {
            this.merge(envfile.parseFileSync(envPath));
        }
    }
}
github tessel / t2-cli / lib / tessel-ssh.js View on Github external
var Client = require('ssh2').Client
  , envfile = require('envfile')
  , config = envfile.parseFileSync(__dirname + '/../config.env')
  ;

function createConnection(callback) {
  // Create a new SSH client connection object
  var conn = new Client()
  // Open up an SSH Connection
  conn.on('ready', function() {
    callback && callback(null, conn);
  })
  conn.on('error', function(err) {
    callback && callback(err);
  }).connect({
    host: config.host,
    port: 22,
    username: config.username,
    privateKey: require('fs').readFileSync(config.keyPath)
github bloom510 / faunadb-nodejs-examples / internals / scripts / utils / env / index.js View on Github external
const fs = require("fs");
const { spawn } = require("child_process");
const { createKey }= require('../fdb');
const envfile = require("envfile");
const appRoot = require("app-root-path");
const envPath = appRoot + "/.env";
const env = envfile.parseFileSync(envPath);

const checkEnv = () => {
  if (!env) {
    fs.writeFileSync(envPath);
  }
};

const writeToEnv = params => {
 /* Write to env */
};

module.exports = { checkEnv, writeToEnv };
github alphagov / pay-selfservice / test / test_helpers / test_env.js View on Github external
'use strict'
const path = require('path')
const envfile = require('envfile')

const TEST_ENV = envfile.parseFileSync(path.join(__dirname, '../test.env'))

for (let property in TEST_ENV) {
  process.env[property] = TEST_ENV[property]
}
github blockapps / blockapps-rest / lib / util / oauth.client.js View on Github external
AAOCAQEATafWoYdQmUxiIsXitgHMV51f15KOWS6vsa+XfKPLFRFIbw8bYl/PdbJp
XoxywIf9rz7/+Hme6JXhIIao26ahXWG34J06CJ3kvnQcFzrUJ4AZLZrs3E0yzsNK
4zgdiPRK3TVCwzqnA6OkajLPuhisheAtoB2T5pR+SeC064cB3lhSgnFS31ePGmgv
b4qiXqr2JW4Db8yW0eKYrfwhf9WoElVlgO1ogqZS+ygeKYFfoNhQ5wQ+c43jDK5G
EDxFZuwghztIpmp2ItFOIxpsiZnEVlHNsq4H6YcZg4XENKhb9/lgIFiYADDbAEcq
pBMYLinJZN+jM/Xddr18fL0obdkk5Q==
-----END CERTIFICATE-----`;

if (!fs.existsSync(envPath)) {
  fs.appendFileSync(envPath, "", function(err) {
    if (err) throw err;
    console.log(".env file is created successfully.");
  });
}

envConfig = envfile.parseFileSync(envPath);

const flows = {
  authorizationCode: "authorization-code",
  clientCredential: "client-credential",
  resourceOwnerPasswordCredential: "resource-owner-password-credential"
};

commander
  .option("-c, --config [path]", "Config file", "config.yaml")
  .option(
    "-p, --port [number]",
    "Port on which to run web server for token exchange",
    "8000"
  )
  .option(
    "-f, --flow [oauth-flow]",
github bloom510 / faunadb-nodejs-examples / auth / fql-auth / bootstrap / index.js View on Github external
* Prerequisites:
 * You must have an  Fauna database with your admin key stored as FDB_ADMIN_KEY in your .env file.
 * This script takes care of the rest by writing the client and server keys for the new database in your .env file.
 * Make sure to replace 'testdb' with your database name.
 *
 * TODO: Make into an interactive shell program to add flexibility, prevent overwrites, etc.
 *
 */

require("dotenv").config();

const fs = require("fs");

const envfile = require("envfile");

const env = envfile.parseFileSync(".env");

const faunadb = require("faunadb");
const {
  Create,
  Collection,
  CreateDatabase,
  CreateCollection,
  CreateIndex,
  CreateKey,
  Database
} = faunadb.query;

let client = new faunadb.Client({ secret: process.env.FDB_FQL_ADMIN_KEY });

const createDB = async () => {
  try {
github badassery / laravel-up / src / actions / publish-environment.ts View on Github external
composeYaml = {
    ...composeYaml,
    services: { ...composeYaml.services, database: dbService }
  };

  await writeFileAsync(destDockerComposePath, jsyaml.dump(composeYaml));

  const envExamplePath = path.join(fullProjectPath, ".env.example");
  const envExampleFileContents = envfile.parseFileSync(envExamplePath);

  const envPath = path.join(fullProjectPath, ".env");
  if (!fs.existsSync(envPath)) {
    shelljs.cp(envExamplePath, envPath);
  }
  const envFileContents = envfile.parseFileSync(envPath);

  const envOverrides = [
    ["DB_HOST", "database"],
    ["DB_USERNAME", "root"],
    ["DB_PASSWORD", envConfig.dbRootPassword],
    ["DB_DATABASE", envConfig.dbName],
    ["DB_CONNECTION", envConfig.engine === POSTGRES ? "pgsql" : "mysql"],
    ["DB_PORT", envConfig.engine === POSTGRES ? 5432 : 3306]
  ];

  envOverrides.forEach(([key, value]) => {
    envFileContents[key] = value;
    envExampleFileContents[key] = value;
  });

  fs.writeFileSync(envPath, envfile.stringifySync(envFileContents));
github jsforce / jsforce / Gruntfile.js View on Github external
preBundleCB: function(b) {
            var filePath = "./test/config/browser/env.js";
            var env = process.env;
            try {
              env = envfile.parseFileSync('./.env');
            } catch(e) {}
            var data = "module.exports=" + JSON.stringify(env) + ";";
            fs.writeFileSync(filePath, data);
          }
        }
github ArkEcosystem / core / packages / core / src / commands / env / set.ts View on Github external
public async run(): Promise {
        const { args, paths } = await this.parseWithNetwork(SetCommand);

        const envFile = `${paths.config}/.env`;

        if (!existsSync(envFile)) {
            this.error(`No environment file found at ${envFile}`);
        }

        const env = envfile.parseFileSync(envFile);

        env[args.key] = args.value;

        writeFileSync(envFile, envfile.stringifySync(env));
    }
}

envfile

Parse and stringify the environment configuration files and format, also known as .env files and dotenv files

Artistic-2.0
Latest version published 9 months ago

Package Health Score

68 / 100
Full package analysis