From 60757a8bb4223230e67661d426fd5c151ce1998a Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Sat, 13 Jan 2024 07:40:49 +0100 Subject: [PATCH] Document how we obtain the name of the cabal config file. --- dist/index.js | 9 +++++++++ lib/setup-haskell.js | 9 +++++++++ src/setup-haskell.ts | 9 +++++++++ 3 files changed, 27 insertions(+) diff --git a/dist/index.js b/dist/index.js index 10d5f2b..89b7a99 100644 --- a/dist/index.js +++ b/dist/index.js @@ -14040,6 +14040,15 @@ async function cabalConfig() { silent: true, listeners: { stdout: append, stderr: append } }); + // The last line of the cabal help text is printing the config file, e.g.: + // + // > You can edit the cabal configuration file to set defaults: + // > <>/.cabal/config + // + // So trimming the last line will give us the name of the config file. + // + // Needless to say this is very brittle, but we secure this by a test + // in Cabal's testsuite: https://github.com/haskell/cabal/pull/9614 return out.toString().trim().split('\n').slice(-1)[0].trim(); } async function run(inputs) { diff --git a/lib/setup-haskell.js b/lib/setup-haskell.js index f74417e..db71ead 100644 --- a/lib/setup-haskell.js +++ b/lib/setup-haskell.js @@ -42,6 +42,15 @@ async function cabalConfig() { silent: true, listeners: { stdout: append, stderr: append } }); + // The last line of the cabal help text is printing the config file, e.g.: + // + // > You can edit the cabal configuration file to set defaults: + // > <>/.cabal/config + // + // So trimming the last line will give us the name of the config file. + // + // Needless to say this is very brittle, but we secure this by a test + // in Cabal's testsuite: https://github.com/haskell/cabal/pull/9614 return out.toString().trim().split('\n').slice(-1)[0].trim(); } async function run(inputs) { diff --git a/src/setup-haskell.ts b/src/setup-haskell.ts index 158d6f1..b8d0134 100644 --- a/src/setup-haskell.ts +++ b/src/setup-haskell.ts @@ -16,6 +16,15 @@ async function cabalConfig(): Promise { silent: true, listeners: {stdout: append, stderr: append} }); + // The last line of the cabal help text is printing the config file, e.g.: + // + // > You can edit the cabal configuration file to set defaults: + // > <>/.cabal/config + // + // So trimming the last line will give us the name of the config file. + // + // Needless to say this is very brittle, but we secure this by a test + // in Cabal's testsuite: https://github.com/haskell/cabal/pull/9614 return out.toString().trim().split('\n').slice(-1)[0].trim(); }