Przeglądaj źródła

Add quotes to user-agent in debug command line

Gaël Métais 10 lat temu
rodzic
commit
6521d24925
1 zmienionych plików z 11 dodań i 3 usunięć
  1. 11 3
      lib/tools/phantomas/phantomasWrapper.js

+ 11 - 3
lib/tools/phantomas/phantomasWrapper.js

@@ -1,6 +1,7 @@
 var async           = require('async');
 var Q               = require('q');
 var ps              = require('ps-node');
+var path            = require('path');
 var debug           = require('debug')('ylt:phantomaswrapper');
 var phantomas       = require('phantomas');
 
@@ -46,8 +47,8 @@ var PhantomasWrapper = function() {
                 'windowPerformance' // overriden
             ].join(','),
             'include-dirs': [
-                'lib/tools/phantomas/custom_modules/core',
-                'lib/tools/phantomas/custom_modules/modules'
+                path.join(__dirname, 'custom_modules/core'),
+                path.join(__dirname, 'custom_modules/modules')
             ].join(',')
         };
 
@@ -55,7 +56,14 @@ var PhantomasWrapper = function() {
         debug('If you want to reproduce the phantomas task only, copy the following command line:');
         var optionsString = '';
         for (var opt in options) {
-            optionsString += ' ' + '--' + opt + '=' + options[opt];
+            var value = options[opt];
+            
+            if ((typeof value === 'string' || value instanceof String) && value.indexOf(' ') >= 0) {
+                value = '"' + value + '"';
+            }
+
+            optionsString += ' ' + '--' + opt + '=' + value;
+
         }
         debug('node node_modules/phantomas/bin/phantomas.js --url=' + task.url + optionsString + ' --verbose');