on master help sign in
Merge pull request #3854 from rbarreiro/search_for_includes_in_getIdrisLibDir

changed js backend to look for includes also in getIdrisLibDir

commit6db4204557bba405c4e903f3520dbdb5ac79cba5 authorNiklas Larsson <metaniklas@gmail.com> dateFri 16 Jun 2017, 00:01 (9 years ago) parentb6b28fe38484ff
2 files changed+17−1
docs/tutorial/miscellany.rst+9 src/IRTS/JavaScript/Codegen.hs+8−1
docs/tutorial/miscellany.rst+9
@@ -494,6 +494,15 @@ And for use in the browser:
494494 %include JavaScript "path/to/external.js"
495495
496496The 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.
497506
498507Including *NodeJS* modules
499508--------------------------
src/IRTS/JavaScript/Codegen.hs+8−1
@@ -64,7 +64,14 @@ data CGConf = CGConf { header :: Text
6464
6565
6666getInclude :: 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
6875
6976getIncludes :: [FilePath] -> IO Text
7077getIncludes l = do