diff options
Diffstat (limited to 'index.js')
-rw-r--r-- | index.js | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -6,6 +6,7 @@ var cp = require('child_process') | |||
6 | , chalk = require('chalk') | 6 | , chalk = require('chalk') |
7 | , lu = require('loader-utils') | 7 | , lu = require('loader-utils') |
8 | , cwd = process.cwd() | 8 | , cwd = process.cwd() |
9 | , MODULE_RE = /^module\s+([\w\.]+)\s+/i | ||
9 | , BOWER_PATTERN = path.join('bower_components', 'purescript-*', 'src') | 10 | , BOWER_PATTERN = path.join('bower_components', 'purescript-*', 'src') |
10 | , PSC_MAKE = 'psc-make' | 11 | , PSC_MAKE = 'psc-make' |
11 | , OUTPUT = 'output' | 12 | , OUTPUT = 'output' |
@@ -42,7 +43,8 @@ module.exports = function(source){ | |||
42 | cmd.on('close', function(e){ | 43 | cmd.on('close', function(e){ |
43 | if (e) callback(e); | 44 | if (e) callback(e); |
44 | else { | 45 | else { |
45 | var module = path.basename(request, '.purs'); | 46 | var result = MODULE_RE.exec(source); |
47 | var module = result.length > 1 ? result[1] : ''; | ||
46 | fs.readFile(path.join(query[OUTPUT] || OUTPUT, module, 'index.js'), 'utf-8', function(e, output){ | 48 | fs.readFile(path.join(query[OUTPUT] || OUTPUT, module, 'index.js'), 'utf-8', function(e, output){ |
47 | if (e) callback(e); | 49 | if (e) callback(e); |
48 | else callback(e, output); | 50 | else callback(e, output); |