且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何运行像“npm install"这样的 bash 命令符合

更新时间:2021-11-07 22:17:46

如果您使用的是默认的 Yesod 脚手架(由 stack 工具生成),那么它确实不包含 Setup.hs(这有点奇怪,作为他们自己的指南 - https://github.com/commercialhaskell/stack/blob/master/doc/GUIDE.md - 建议将其作为一种好的做法)

If you're using the default Yesod scaffolding (generated by stack tool), then it indeed doesn't contain Setup.hs (which is a bit weird, as their own guide - https://github.com/commercialhaskell/stack/blob/master/doc/GUIDE.md - recommends having it as a good practice)

Setup.hs 应该位于主项目目录中(与 stack.ymlyourproject.cabal 所在的位置相同)并且内容应该与包含的示例大致相同(defaultMainWithHooks 是关键部分).

Setup.hs should be located in main project directory (same where stack.yml and yourproject.cabal are located) and content should be roughly the same as in your included example (defaultMainWithHooks is the key part).

钩子的使用细节在https://www.haskell.org/cabal/users-guide/developing-packages.htmlcabal 规范:https://hackage.haskell.org/package/Cabal-1.24.0.0/docs/Distribution-Simple.html

Details of hooks usage are specified in https://www.haskell.org/cabal/users-guide/developing-packages.html and in cabal spec: https://hackage.haskell.org/package/Cabal-1.24.0.0/docs/Distribution-Simple.html

顺便说一句,目前 stack 本身不支持预构建钩子(有关详细信息,请参阅:https://github.com/commercialhaskell/stack/issues/503),所以你必须坚持使用 cabal 提供的 - 这就是 Setup.hs 来自.

BTW, for now stack doesn't support pre-build hooks on its own (for details see: https://github.com/commercialhaskell/stack/issues/503), so you have to stick to ones provided by cabal - that's where Setup.hs comes from.