Runner.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { test } from 'ava';
  2. import { Runner } from '../';
  3. import { spawnAsync } from '../dist/lib/util';
  4. const dir = './assets/project/';
  5. test.serial('commandline', async (t) => {
  6. const { code, signal } = await spawnAsync('node', `./dist/bin/run.js ${ dir } 233`.split(' '), {
  7. stdio: 'inherit',
  8. env: Object.assign({}, process.env, {
  9. NWJS_MIRROR: process.env.CI ? '' : 'https://npm.taobao.org/mirrors/nwjs/',
  10. }),
  11. });
  12. t.is(code, 233);
  13. });
  14. test.serial('commandline --detached', async (t) => {
  15. const mirror = process.env.CI ? '' : '--mirror https://npm.taobao.org/mirrors/nwjs/';
  16. const { code, signal } = await spawnAsync('node', `./dist/bin/run.js ${ mirror } --detached ${ dir } 233`.split(' '), {
  17. stdio: 'inherit',
  18. });
  19. t.is(code, 0);
  20. });
  21. test.serial('module', async (t) => {
  22. const mirror = process.env.CI ? undefined : 'https://npm.taobao.org/mirrors/nwjs/';
  23. const runner = new Runner({
  24. mirror,
  25. }, [ dir, '233' ]);
  26. const code = await runner.run();
  27. t.is(code, 233);
  28. });