Beispiel #1
0
    it("should call phantomjs exec with expected args", function() {
      sandbox.stub(childProcess, "execFile");

      scrape("http://invalid.test/");

      sinon.assert.calledOnce(childProcess.execFile);
      expect(childProcess.execFile.getCall(0).args[0]).to.match(/phantomjs/);
      expect(childProcess.execFile.getCall(0).args[1]).to.include("http://invalid.test/");
      expect(childProcess.execFile.getCall(0).args[1][2]).to.match(/Readability\.js/);
    });
Beispiel #2
0
    afterEach(function() {
        if (child_process.execFile.restore) {
            child_process.execFile.restore();
        }
        if (registry.addModule.restore) {
            registry.addModule.restore();
        }
        if (registry.removeModule.restore) {
            registry.removeModule.restore();
        }
        if (typeRegistry.removeModule.restore) {
            typeRegistry.removeModule.restore();
        }
        if (registry.getModuleInfo.restore) {
            registry.getModuleInfo.restore();
        }
        if (typeRegistry.getModuleInfo.restore) {
            typeRegistry.getModuleInfo.restore();
        }

        if (require('fs').statSync.restore) {
            require('fs').statSync.restore();
        }

    });
Beispiel #3
0
function runQueue() {
  if (!heyuQueue.isRunning && heyuQueue.items.length > 0) {
    heyuQueue.isRunning = true;
    var args = heyuQueue.items.shift();

    if (args.length > 1) {
      // wrap callback with another function to toggle isRunning
      var callback = args[args.length - 1];
      args[args.length - 1] = function() {
        callback.apply(null, arguments);
        heyuQueue.isRunning = false;
        runQueue();
      };
    } else {
      // add callback to toggle isRunning
      args[args.length] = function() {
        heyuQueue.isRunning = false;
        runQueue();
      };
      args.length = args.length + 1;
    }
    debug("heyuCommand", args[1].join(" "));
    // debug("exec", JSON.stringify(args));
    exec.apply(null, args);
  }
}
Beispiel #4
0
 parseImports(full_path, false, (err, srcs) => {
   if (err) return reject(err)
   let execWcc = execFile.bind(null, wcc, wxml_args.concat(srcs))
   if (isLinux) {
     execWcc = exec.bind(null, [wcc].concat(wxml_args).concat(srcs).join(' '))
   }
   if (useDefaultCompiler) {
     if (wxmlMsgFlag) {
       console.log(chalk.yellow('Using wcc.exe to transpile wxml:'))
       wxmlMsgFlag = 0
     }
     execWcc( {maxBuffer: 1024 * 600}, (err, stdout, stderr) => {
       if (err) {
         console.error(err.stack)
         return reject(new Error(`${full_path} 编译失败,请检查`))
       }
         //if (stderr) return reject(new Error(stderr))
       cache[full_path] = stdout
       resolve(stdout)
     })
   } else {
     if (wxmlMsgFlag) {
       console.log(chalk.yellow('Using wxml-compiler to transpile wxml:'))
       wxmlMsgFlag = 0
     }
     const res = wxmlTranspiler.wxmlCompile(srcs).render
     cache[full_path] = res
     resolve(res)
   }
 })
Beispiel #5
0
 _.forEach(installTargets, function(installDir) {
   tasks.push(
     child_process.execFile.bind(child_process, 'go', ['install'], {
       cwd: installDir,
       env: that.testEnv
     })
   );
 });
 readDir: function(branch, workingDir, path, callback) {
     async.waterfall([
         ensureBranchAndStash.bind(null, branch, workingDir),
         exec.bind(exec, 'git', ['ls-tree', stashForBranch(branch) + ':' + path], { cwd: workingDir }),
         function(stdout, stderr, cb) {
             cb(null, treeFromString(stdout));
         }
     ], callback);
 },
Beispiel #7
0
 parseImports(full_path, true, (err, srcs) => {
   if (err) return reject(err)
   cache.setWxssMap(srcs)
   let execWcsc = execFile.bind(null, wcsc, wxss_args.concat(srcs))
   if (isLinux) {
     execWcsc = exec.bind(null, [wcsc].concat(wxss_args).concat(srcs).join(' '))
   }
   if (useDefaultCompiler) {
     if (wxssMsgFlag) {
       console.log(chalk.yellow('Using wcsc.exe to build: '))
       wxssMsgFlag = 0
     }
     execWcsc({ maxBuffer: 1024 * 600 }, (err, stdout, stderr) => {
       if (err) {
         console.error(err.stack)
         return reject(new Error(`${full_path} 编译失败,请检查`))
       }
       wxssSourcemap(full_path, stdout).then(content => {
         cache[full_path] = content
         resolve(content)
       }, reject)
     })
   } else {
     if (wxssMsgFlag) {
       console.log(
         chalk.yellow('Using wxss-transpiler to transpile wxss: ')
       )
       wxssMsgFlag = 0
     }
     wxssTranspile(srcs).then(stdout => {
       wxssSourcemap(full_path, stdout).then(content => {
         cache[full_path] = content
         resolve(content)
       }, reject)
     })
   }
 })
Beispiel #8
0
	execFile: function() {
		var c = child_process.execFile.apply(null, arguments);
		decorate(c);
		return c;
	}
Beispiel #9
0
 .expect(function() {
   expect(childProcess.execFile.getCall(0).args[1]).to.contain("custom ua");
 })
Beispiel #10
0
'use strict';
var path = require('path');
var execFile = require('child_process').execFile;
module.exports = execFile.bind(null, process.execPath, [path.resolve(__dirname, 'output-level.js')]);
Beispiel #11
0
 PKGS.forEach(function(p) {
   tasks.push(
     child_process.execFile.bind(
       child_process, 'go', ['get', p], {env: that.testEnv}));
 });