2018-06-05 16:05:49 +02:00
|
|
|
'use strict';
|
2018-06-15 14:23:44 +02:00
|
|
|
|
|
|
|
const common = require('../common');
|
|
|
|
const fixtures = require('../common/fixtures');
|
|
|
|
const { spawn } = require('child_process');
|
2018-06-05 16:05:49 +02:00
|
|
|
const assert = require('assert');
|
2018-06-15 14:23:44 +02:00
|
|
|
|
|
|
|
const entry = fixtures.path('/es-modules/cjs.js');
|
|
|
|
|
|
|
|
const child = spawn(process.execPath, ['--experimental-modules', entry]);
|
2018-12-21 19:20:21 +01:00
|
|
|
let stderr = '';
|
|
|
|
child.stderr.setEncoding('utf8');
|
2018-06-15 14:23:44 +02:00
|
|
|
child.stderr.on('data', (data) => {
|
2018-12-21 19:20:21 +01:00
|
|
|
stderr += data;
|
2018-06-15 14:23:44 +02:00
|
|
|
});
|
2018-12-21 19:20:21 +01:00
|
|
|
let stdout = '';
|
|
|
|
child.stdout.setEncoding('utf8');
|
2018-06-15 14:23:44 +02:00
|
|
|
child.stdout.on('data', (data) => {
|
2018-12-21 19:20:21 +01:00
|
|
|
stdout += data;
|
2018-06-15 14:23:44 +02:00
|
|
|
});
|
2018-12-16 04:20:05 +01:00
|
|
|
child.on('close', common.mustCall((code, signal) => {
|
2018-06-15 14:23:44 +02:00
|
|
|
assert.strictEqual(code, 0);
|
2018-12-16 04:20:05 +01:00
|
|
|
assert.strictEqual(signal, null);
|
2018-12-21 19:20:21 +01:00
|
|
|
assert.strictEqual(stdout, 'executed\n');
|
|
|
|
assert.strictEqual(stderr, `(node:${child.pid}) ` +
|
|
|
|
'ExperimentalWarning: The ESM module loader is experimental.\n');
|
2018-06-15 14:23:44 +02:00
|
|
|
}));
|