const compile = require('./compile');
-const PsModuleMap = require('./PsModuleMap');
+const PsModuleMap = require('./purs-module-map');
function UnknownModuleError() {
this.name = '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);
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)));
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);
}
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 => ({
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());
}