Skip to content

Commit 7bb9284

Browse files
Dirty deployables are now added to git after being updated (#16)
* Dirty deployables are now added to git after being updated * changed slice to replace * Changed log to warn
1 parent eebcdbf commit 7bb9284

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "polyapi",
3-
"version": "0.23.26",
3+
"version": "0.23.27",
44
"description": "Poly is a CLI tool to help create and manage your Poly definitions.",
55
"license": "MIT",
66
"repository": {

src/commands/prepare.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,22 @@ export const prepareDeployables = async (
160160
writeUpdatedDeployable(deployable, disableDocs),
161161
),
162162
);
163+
const staged = shell.exec('git diff --name-only --cached')
164+
.toString().split('\n').filter(Boolean);
165+
const rootPath: string = shell.exec('git rev-parse --show-toplevel', {silent:true})
166+
.toString('utf8').replace('\n', '');
167+
for (const deployable of dirtyDeployables) {
168+
try{
169+
const deployableName = deployable.file.replace(rootPath, '');
170+
if (staged.includes(deployableName)) {
171+
shell.echo(`Staging ${deployableName}`);
172+
shell.exec(`git add ${deployableName}`);
173+
}
174+
}
175+
catch (error) {
176+
console.warn(error);
177+
}
178+
}
163179
}
164180
console.log('Poly deployments are prepared.');
165181
await saveDeployableRecords(parsedDeployables);

0 commit comments

Comments
 (0)