forked from adamlaska/ts-graphql-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtransform.js
More file actions
22 lines (20 loc) · 778 Bytes
/
transform.js
File metadata and controls
22 lines (20 loc) · 778 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const assert = require('assert');
const path = require('path');
const { execSync } = require('child_process');
const webpack = require('webpack');
const { print } = require('graphql/language');
async function run() {
const config = require('../../project-fixtures/transformation-prj/webpack.config.js');
const compiler = webpack({ ...config, mode: 'production' });
const stats = await new Promise((res, rej) => {
compiler.run((err, stats) => {
if (err) return rej(err);
return res(stats);
});
});
assert(!stats.hasErrors());
const distFilePath = path.resolve(stats.toJson().outputPath, 'main.js');
const result = execSync(`node ${distFilePath}`);
assert.equal(typeof print(JSON.parse(result.toString())), 'string');
}
module.exports = run;