X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2Fide.js;h=d3707a40ac4eecb88f50350eb1e6a691edbe3c38;hb=8d4bd16e97e5e315d879fbfae04f52073b9e6a2b;hp=ac80789c1ad377ca180afd974e273081b91eaa0d;hpb=7f0547d4e02d927e766de340152a2f75b659d889;p=github%2Ffretlink%2Fpurs-loader.git diff --git a/src/ide.js b/src/ide.js index ac80789..d3707a4 100644 --- a/src/ide.js +++ b/src/ide.js @@ -22,7 +22,7 @@ const dargs = require('./dargs'); const compile = require('./compile'); -const PsModuleMap = require('./PsModuleMap'); +const PsModuleMap = require('./purs-module-map'); function UnknownModuleError() { this.name = 'UnknownModuleError'; @@ -36,15 +36,15 @@ UnknownModuleError.prototype.constructor = UnknownModuleError; module.exports.UnknownModuleError = UnknownModuleError; function spawnIdeClient(body, options) { - const ideClientCommand = 'purs'; + const ideClientCommand = options.pscIdeClient || 'purs'; - const ideClientArgs = ['ide', 'client'].concat(dargs(options.pscIdeArgs)); + const ideClientArgs = (options.pscIdeClient ? [] : ['ide', 'client']).concat(dargs(options.pscIdeClientArgs)); const stderr = []; const stdout = []; - debug('ide client %s %o %o', ideClientCommand, ideClientArgs, body); + debug('ide client %s %o %O', ideClientCommand, ideClientArgs, body); return new Promise((resolve, reject) => { const ideClient = spawn(ideClientCommand, ideClientArgs); @@ -144,9 +144,9 @@ function formatIdeResult(result, options, index, length) { module.exports.connect = function connect(psModule) { const options = psModule.options - const serverCommand = 'purs'; + const serverCommand = options.pscIdeServer || 'purs'; - const serverArgs = ['ide', 'server'].concat(dargs(Object.assign({ + const serverArgs = (options.pscIdeServer ? [] : ['ide', 'server']).concat(dargs(Object.assign({ outputDirectory: options.output, '_': options.src }, options.pscIdeServerArgs))); @@ -202,16 +202,16 @@ module.exports.rebuild = function rebuild(psModule) { const body = { command: 'rebuild', - params: { + params: Object.assign({ file: psModule.srcPath, - } + }, options.pscIdeRebuildArgs) }; const parseResponse = response => { try { const parsed = JSON.parse(response); - debugVerbose('parsed JSON response: %o', parsed); + debugVerbose('parsed JSON response: %O', parsed); return Promise.resolve(parsed); } @@ -224,7 +224,7 @@ module.exports.rebuild = function rebuild(psModule) { const result = Array.isArray(parsed.result) ? parsed.result : []; return Promise.map(result, (item, i) => { - debugVerbose('formatting result %o', item); + debugVerbose('formatting result %O', item); return formatIdeResult(item, options, i, result.length); }).then(formatted => ({ @@ -254,7 +254,7 @@ module.exports.rebuild = function rebuild(psModule) { return isModuleNotFound || isUnknownModule || isUnknownModuleImport; })) { - debug('failed to rebuild because the module is unknown') + debug('module %s was not rebuilt because the module is unknown', psModule.name); return Promise.reject(new UnknownModuleError()); }