trigger 1.0.1.0 → 1.0.2.0
raw patch · 5 files changed
+12/−55 lines, 5 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Parser: RunConfig :: Maybe Text -> Text -> Maybe [(Text, Text)] -> RunConfig
- Parser: [_command] :: RunConfig -> Text
- Parser: [_env] :: RunConfig -> Maybe [(Text, Text)]
- Parser: [_workingDir] :: RunConfig -> Maybe Text
- Parser: data RunConfig
- Parser: instance Data.Aeson.Types.FromJSON.FromJSON Parser.RunConfig
- Parser: instance GHC.Classes.Eq Parser.RunConfig
- Parser: instance GHC.Generics.Generic Parser.RunConfig
- Parser: instance GHC.Show.Show Parser.RunConfig
- Parser: Config :: [Text] -> [Text] -> Maybe [Text] -> Maybe [Text] -> Maybe [RunConfig] -> Config
+ Parser: Config :: [Text] -> [Text] -> Maybe [Text] -> Maybe [Text] -> Maybe [Text] -> Config
- Parser: [_run] :: Config -> Maybe [RunConfig]
+ Parser: [_run] :: Config -> Maybe [Text]
Files
- README.md +2/−9
- src/Parser.hs +1/−11
- src/Trigger.hs +7/−33
- test/ParserSpec.hs +1/−1
- trigger.cabal +1/−1
README.md view
@@ -57,11 +57,7 @@ tasks: - "stack build" run:- - command: "target/executable"- workingDir: "target"- env:- - ["HOST", "localhost"]- - ["PORT", "1234"]+ - "target/executable" ``` Which consists of:@@ -70,7 +66,4 @@ - `files`: one or more file globs. Files that don't match will not trigger. - `ignore`: (optional) one or more file globs. Overrides the above file globs to exclude particular files. - `tasks`: (optional) one or more tasks, which are run sequentially in the foreground. Any error will stop subsequent tasks.-- `run`: (optional) one or more background processes. *Note: this executes the command directly, rather than using the shell, to improve shutdown behaviour.*- - `command`: command and arguments to run in background. *Note: this command is relative to where you start trigger, not the `workingDir`.*- - `workingDir`: (optional) override the working directory of the process.- - `env`: (optional) additional environment variables for the process+- `run`: (optional) one or more background processes.
src/Parser.hs view
@@ -2,7 +2,6 @@ module Parser ( Config(..)- , RunConfig(..) , loadAndParse ) where @@ -15,19 +14,10 @@ , _files :: [Text] , _ignore :: Maybe [Text] , _tasks :: Maybe [Text]- , _run :: Maybe [RunConfig]+ , _run :: Maybe [Text] } deriving (Eq, Show, Generic) instance Y.FromJSON Config where- parseJSON = genericParseJSON defaultOptions {fieldLabelModifier = drop 1}--data RunConfig = RunConfig- { _workingDir :: Maybe Text- , _command :: Text- , _env :: Maybe [(Text,Text)]- } deriving (Eq, Show, Generic)--instance Y.FromJSON RunConfig where parseJSON = genericParseJSON defaultOptions {fieldLabelModifier = drop 1} loadAndParse :: FilePath -> IO [Config]
src/Trigger.hs view
@@ -75,11 +75,12 @@ ExitSuccess -> return () ExitFailure _ -> throwIO exitCode -startProcess :: RunConfig -> IO RunningProcess-startProcess RunConfig {..} = do- (_, _, _, processHandle) <- P.createProcess_ (toS _command) $ process _workingDir _env _command- printStartingRunTask _command- return $ RunningProcess _command processHandle+startProcess :: Text -> IO RunningProcess+startProcess command = do+ (_, _, _, processHandle) <- P.createProcess_ (toS command) $ (P.shell (toS command)) { P.use_process_jobs = True+ , P.create_group = True }+ printStartingRunTask command+ return $ RunningProcess command processHandle terminate :: RunningProcess -> IO () terminate RunningProcess {..} = do@@ -87,34 +88,7 @@ exit <- P.getProcessExitCode processHandle case exit of Nothing -> do- P.terminateProcess processHandle+ P.interruptProcessGroupOf processHandle exitCode <- P.waitForProcess processHandle printTerminated cmd exitCode Just exitCode -> printAlreadyTerminated cmd exitCode--process :: Maybe Text -> Maybe [(Text, Text)] -> Text -> P.CreateProcess-process workingDir env command =- P.CreateProcess- { cmdspec = splitCommand command- , cwd = map toS workingDir- , env = map (map (toS A.*** toS)) env- , std_in = P.Inherit- , std_out = P.Inherit- , std_err = P.Inherit- , close_fds = False- , create_group = False- , delegate_ctlc = False- , detach_console = False- , create_new_console = False- , new_session = False- , child_group = Nothing- , child_user = Nothing- , use_process_jobs = True- }--splitCommand :: Text -> P.CmdSpec-splitCommand command =- let cmdAndArgs = T.words command- cmd = fromMaybe T.empty (head cmdAndArgs)- args = L.tail cmdAndArgs- in P.RawCommand (toS cmd) (map toS args)
test/ParserSpec.hs view
@@ -11,5 +11,5 @@ it "can parse example.yaml" $ do config <- loadAndParse "example/example.yaml" config `shouldBe` - [ Config ["src"] ["**/*.hs"] Nothing (Just ["stack build"]) (Just [ (RunConfig (Just "code") "stack exec" (Just [("HOST", "localhost"), ("PORT", "1234")]))])+ [ Config ["src"] ["**/*.hs"] Nothing (Just ["stack build"]) (Just [ "stack exec" ]) , Config ["client"] ["**/*.elm"] (Just ["Api.elm"]) (Just ["elm-make"]) Nothing]
trigger.cabal view
@@ -1,5 +1,5 @@ name: trigger-version: 1.0.1.0+version: 1.0.2.0 homepage: https://github.com/rhyskeepence/trigger license: BSD3 license-file: LICENSE