Skip to content

Instantly share code, notes, and snippets.

@zhigang1992 zhigang1992/use.ts Secret
Last active Mar 10, 2019

What would you like to do?
swiping firebase env and application env
import chalk from "chalk";
import * as meow from "meow";
import * as fs from "fs";
import * as ora from "ora";
import * as path from "path";
import { run } from "./utils/run";
(async () => {
const cli = meow(
./use.ts [dev|staging|prod]
const env: string | undefined = cli.input[0];
if (!env) {
try {
const currentEnv = fs
.readFileSync(path.resolve(__dirname, "./.current_project"), "utf-8")
console.log(`Current project: ${chalk.bold(currentEnv)}`);
} catch {
} else {
const spinner = ora(`Set env to: ${chalk.bold(env)}\n`).start();
try {
await run(`../node_modules/.bin/firebase use ${env}`);
await run(
`ln -f ./configs/${env}/GoogleService-Info.plist ../app/ios/GoogleService-Info.plist`
await run(
`ln -f ./configs/${env}/google-services.json ../app/android/app/google-services.json`
await run(
`ln -f ./configs/${env}/Info.plist ../app/ios/mercy/Info.plist`
await run(
`echo ${env} > ${path.resolve(__dirname, "./.current_project")}`
spinner.succeed(`Successfully set project to: ${chalk.bold(env)}`);
} catch {`Failed set project to: ${chalk.bold(env)}`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.