From 76d96017b3311bb0cf4569c21aa2cd5d7bfe3e51 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Fri, 9 Oct 2020 14:42:28 -0400 Subject: [PATCH 1/2] Revert "Embed neuron-search script" --- CHANGELOG.md | 4 ---- neuron/neuron.cabal | 6 +++--- neuron/src/app/Neuron/CLI/Search.hs | 22 +++++----------------- 3 files changed, 8 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d8a0b28cf..e4de39bb2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,5 @@ # Change Log for neuron -## 1.0.1.0 - -- Fix broken `neuron search` in static binary (#429) - ## 1.0.0.0 - Updates diff --git a/neuron/neuron.cabal b/neuron/neuron.cabal index 3c85b63fb..13e2fd0b2 100644 --- a/neuron/neuron.cabal +++ b/neuron/neuron.cabal @@ -1,7 +1,7 @@ cabal-version: 2.4 name: neuron -- This version must be in sync with what's in Default.dhall -version: 1.0.1.0 +version: 1.0.0.0 license: AGPL-3.0-only copyright: 2020 Sridhar Ratnakumar maintainer: srid@srid.ca @@ -135,6 +135,7 @@ common app-common foldl, filepath, dhall >= 1.30, + which, unix, megaparsec >= 8.0, dependent-sum >= 0.7, @@ -145,8 +146,7 @@ common app-common with-utf8, shower, either, - uri-encode, - temporary + uri-encode -- Everything below will have to be stripped away, if whoever uses this repo -- will want to avoid non-core dependencies. Cabal doesn't seem to provide a way diff --git a/neuron/src/app/Neuron/CLI/Search.hs b/neuron/src/app/Neuron/CLI/Search.hs index 802e2b1c4..ef82c83a2 100644 --- a/neuron/src/app/Neuron/CLI/Search.hs +++ b/neuron/src/app/Neuron/CLI/Search.hs @@ -11,9 +11,7 @@ module Neuron.CLI.Search ) where -import Data.FileEmbed (embedOneStringFileOf) import qualified Data.Text as Text -import Data.Text.IO (hPutStr) import Development.Shake (Action) import Neuron.CLI.Rib ( SearchBy (SearchByContent, SearchByTitle), @@ -22,13 +20,11 @@ import Neuron.CLI.Rib import Neuron.Config.Type (Config, getZettelFormats) import Neuron.Reader.Type (ZettelFormat (ZettelFormat_Org), zettelFormatToExtension) import Relude -import System.IO (hClose) -import System.IO.Temp (withSystemTempFile) -import System.Posix.Files (setFileMode) -import System.Posix.Process (executeFile) +import System.Posix.Process +import System.Which -searchScript :: Text -searchScript = $(embedOneStringFileOf ["./src-bash/neuron-search", "./neuron/src-bash/neuron-search"]) +neuronSearchScript :: FilePath +neuronSearchScript = $(staticWhich "neuron-search") searchScriptArgs :: (NonEmpty ZettelFormat) -> SearchCommand -> [String] searchScriptArgs formats SearchCommand {..} = @@ -47,16 +43,8 @@ interactiveSearch notesDir searchCmd config = zettelFormats <- getZettelFormats config if searchBy searchCmd == SearchByTitle && ZettelFormat_Org `elem` toList zettelFormats then fail "search is not supported for .org files" - else liftIO $ do - asExecutableScript "neuron-search" searchScript $ \scriptFile -> do - execScript scriptFile $ notesDir : searchScriptArgs zettelFormats searchCmd + else liftIO $ execScript neuronSearchScript $ notesDir : searchScriptArgs zettelFormats searchCmd where - asExecutableScript k s f = - withSystemTempFile k $ \fp hdl -> do - hPutStr hdl s - hClose hdl - setFileMode fp 0o700 - f fp execScript scriptPath args = -- We must use the low-level execvp (via the unix package's `executeFile`) -- here, such that the new process replaces the current one. fzf won't work From 94ac411b103b48d3c271efd0fd454d297b7bedb4 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Fri, 9 Oct 2020 14:46:45 -0400 Subject: [PATCH 2/2] up ver --- CHANGELOG.md | 8 ++++++++ neuron/neuron.cabal | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4de39bb2..4f2810301 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Change Log for neuron +## Unreleased + +- Revert #429 for neuron-search regression + +## 1.0.1.0 + +- Fix broken `neuron search` in static binary (#429) + ## 1.0.0.0 - Updates diff --git a/neuron/neuron.cabal b/neuron/neuron.cabal index 13e2fd0b2..0a527c4c6 100644 --- a/neuron/neuron.cabal +++ b/neuron/neuron.cabal @@ -1,7 +1,7 @@ cabal-version: 2.4 name: neuron -- This version must be in sync with what's in Default.dhall -version: 1.0.0.0 +version: 1.0.2.0 license: AGPL-3.0-only copyright: 2020 Sridhar Ratnakumar maintainer: srid@srid.ca