on iko/ghcjs-patch-master help sign in
Add error message for empty src (#320)

When a project's source directory is empty (i.e. no files have been added to the project's corresponding git repo), a more friendly error message will now be printed

commitcb8e3883b77cddaf847c56bf1f8fff66009f86ea authorDavid Cao <6006837+dcao@users.noreply.github.com> dateMon 18 Nov 2019, 15:27 (7 years ago) parent2e4b4eb
1 file changed+7
lib/call-cabal-project-to-nix.nix+7
lib/call-cabal-project-to-nix.nix+7
@@ -170,6 +170,13 @@ let
170170 ) (''
171171 tmp=$(mktemp -d)
172172 cd $tmp
173+ # if maybeCleanedSource is empty, this means it's a new
174+ # project where the files haven't been added to the git
175+ # repo yet. We fail early and provide a useful error
176+ # message to prevent headaches (#290).
177+ if [ -z "$(ls -A ${maybeCleanedSource})" ];
178+ echo "cleaned source is empty. Did you forget to 'git add -A'?"; exit 1;
179+ fi
173180 cp -r ${maybeCleanedSource}/* .
174181 chmod +w -R .
175182 ${fixedProject.makeFixedProjectFile}