on master help sign in
Merge pull request #3854 from rbarreiro/search_for_includes_in_getIdrisLibDir
6db4204Niklas Larsson
docs/tutorial/miscellany.rst+9
@@ -494,6 +494,15 @@ And for use in the browser:
494 %include JavaScript "path/to/external.js"
494 %include JavaScript "path/to/external.js"
495
495
496The given files will be added to the top of the generated code.
496The given files will be added to the top of the generated code.
497+For library packages you can also use the ipkg objs option to include the
498+js file in the installation, and use
499+
500+.. code-block:: idris
501+
502+ %include Node "package/external.js"
503+
504+This javascript and node backends idris will also lookup for the file on
505+on that location.
497
506
498Including *NodeJS* modules
507Including *NodeJS* modules
499--------------------------
508--------------------------
src/IRTS/JavaScript/Codegen.hs+8−1
@@ -64,7 +64,14 @@ data CGConf = CGConf { header :: Text
64
64
65
65
66getInclude :: FilePath -> IO Text
66getInclude :: FilePath -> IO Text
67−getInclude p = TIO.readFile p
67+getInclude p =
68+ do
69+ libs <- getIdrisLibDir
70+ let libPath = libs </> p
71+ exitsInLib <- doesFileExist libPath
72+ if exitsInLib then
73+ TIO.readFile libPath
74+ else TIO.readFile p
68
75
69getIncludes :: [FilePath] -> IO Text
76getIncludes :: [FilePath] -> IO Text
70getIncludes l = do
77getIncludes l = do