Skip to content
This repository was archived by the owner on Jun 4, 2023. It is now read-only.

Commit 1d2d861

Browse files
committed
Added environment flag
1 parent b94d453 commit 1d2d861

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

stackbit-pull.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,15 @@ if (require.main === module) {
134134
commander
135135
.option('--stackbit-pull-api-url <stackbitPullApiUrl>', '[required] stackbit pull API URL')
136136
.option('--stackbit-api-key <stackbitApiKey>', '[required] stackbit API key, can be also specified through STACKBIT_API_KEY environment variable')
137+
.option('--environment <environment>', '[optional] environment to pull data for')
137138
.parse(process.argv);
138139

139140
const stackbitPullApiUrl = commander['stackbitPullApiUrl'];
140141
const apiKey = process.env['STACKBIT_API_KEY'] || commander['stackbitApiKey'];
141142

143+
// Environment to pull data for, defaults to Netlify's BRANCH
144+
const environment = commander['environment'] || process.env['BRANCH'];
145+
142146
if (!stackbitPullApiUrl) {
143147
commander.help(helpText => helpText + `\nError: '--stackbit-pull-api-url' argument must be specified\n\n`);
144148
}
@@ -149,7 +153,7 @@ if (require.main === module) {
149153

150154
console.log(`fetching data for project from ${stackbitPullApiUrl}`);
151155

152-
return pull({stackbitPullApiUrl, apiKey}).then(response => {
156+
return pull({stackbitPullApiUrl, apiKey, environment}).then(response => {
153157
for (let i = 0; i < response.length; i++) {
154158
const fullPath = path.join(process.cwd(), response[i].filePath);
155159
fse.ensureDirSync(path.dirname(fullPath));

0 commit comments

Comments
 (0)