]> git.immae.eu Git - github/fretlink/purs-loader.git/blobdiff - src/ide.js
Fix package.json
[github/fretlink/purs-loader.git] / src / ide.js
index ac80789c1ad377ca180afd974e273081b91eaa0d..d3707a40ac4eecb88f50350eb1e6a691edbe3c38 100644 (file)
@@ -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());
       }