Skip to content

Commit

Permalink
💫 added context parsing based on currently checked out git branch #1
Browse files Browse the repository at this point in the history
  • Loading branch information
8eecf0d2 committed Oct 15, 2018
1 parent 1b69acf commit 16358a5
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/ts/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as fs from "fs";
import * as path from "path";
import * as program from "commander";
import * as toml from "toml";
import * as gitBranch from "git-branch";

import { Netlify } from "./netlify";
import { Server } from "./server";
Expand Down Expand Up @@ -34,7 +35,18 @@ program
throw new Error(`Could not locate "${netlifyFileOption}" file.`);
}

const server = new Server(toml.parse(fs.readFileSync(path.join(process.cwd(), program.netlify), "utf8")), program.port || 9000);
const netlifyConfig = toml.parse(fs.readFileSync(path.join(process.cwd(), program.netlify), "utf8"));

const currentBranch = gitBranch.sync();

if(netlifyConfig.context && netlifyConfig.context[currentBranch]) {
netlifyConfig.build = {
...netlifyConfig.build,
...netlifyConfig.context[currentBranch],
}
}

const server = new Server(netlifyConfig, program.port || 9000);
await server.listen();

if(webpackConfigExists) {
Expand Down

0 comments on commit 16358a5

Please sign in to comment.