UNPKG

1 kBtext/coffeescriptView Raw
1{join} = require 'path'
2findProjectRoot = require './findProjectRoot'
3logger = require 'torch'
4
5# Should be an object that exposes:
6# - Project-relative path helper
7# - General project-relative loader
8# - Project-relative Axiom extension loader
9module.exports =
10
11 # The root of the project.
12 # Determined relative to the value of process.cwd()
13 # in the calling context of 'makeLoader'.
14 projectRoot: findProjectRoot(process.cwd())
15
16 # Relative path construction helper.
17 # Creates paths prefixed by the value of 'loader.projectRoot'.
18 rel: (args...) ->
19 join(@projectRoot, args...)
20
21 # Calls 'require' on a subpath constructed by prefixing
22 # 'path' with the path to the project root.
23 # Returns 'undefined' if no module was found.
24 retrieve: (args...) ->
25 require @rel(args...)
26
27 # Require an Axiom extension module with name 'axiom-<name>'
28 # installed in the 'node_modules' folder of the project root.
29 retrieveExtension: (name) ->
30 @retrieve 'node_modules', "axiom-#{name}"