From 8415172328c8e70d4854ef9246b2c3600079072a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carl-Gerhard=20Lindesva=CC=88rd?= Date: Mon, 11 Mar 2024 20:07:42 +0100 Subject: [PATCH] check uncommitted files #1 --- tooling/publish/publish.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tooling/publish/publish.ts b/tooling/publish/publish.ts index b27dc0ce..8bb65a91 100644 --- a/tooling/publish/publish.ts +++ b/tooling/publish/publish.ts @@ -24,7 +24,24 @@ function exit(message: string, error?: unknown) { process.exit(1); } +function checkUncommittedChanges() { + try { + const changedFiles = execSync('git ls-files --exclude-standard --others') + .toString() + .trim(); + if (changedFiles !== '') { + throw new Error('Uncommitted changes'); + } + execSync('git diff HEAD --exit-code'); + console.log('✅ No uncommitted changes'); + } catch (error) { + exit('Uncommitted changes', error); + } +} + function main() { + checkUncommittedChanges(); + const args = arg({ // Types '--version': String,