Skip to content

Commit 2b4758e

Browse files
committedFeb 22, 2025
updating gulpfile.js
1 parent a441d6d commit 2b4758e

File tree

3 files changed

+898
-70
lines changed

3 files changed

+898
-70
lines changed
 

‎gulpfile.js

+27-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
const { series } = require('gulp');
2-
const { exec } = require('child_process');
2+
const { exec, spawn, spawnSync } = require('child_process');
33
const { readdirSync, rmSync, copyFileSync } = require('fs');
4+
const path = require('path');
45
const chalk = require('chalk');
6+
const tsc = mocha = path.resolve(__dirname, './node_modules/typescript/bin/tsc');
7+
const wp = mocha = path.resolve(__dirname, './node_modules/webpack/bin/webpack');
58

69
const paths = {
710
out: './dist',
@@ -10,7 +13,25 @@ const paths = {
1013
webpackName: 'ts-react-json-table.js'
1114
};
1215

13-
function run(cmd, onClose){
16+
function run(cmd, args, cb){
17+
console.log();
18+
19+
const status = spawnSync(cmd, args, {
20+
cwd: process.cwd(),
21+
env: process.env,
22+
stdio: [process.stdin, process.stdout, process.stderr],
23+
encoding: 'utf-8'
24+
}).status;
25+
26+
if(status !== 0){
27+
throw Error(`Failed to execute command '${args.join()}'`);
28+
}
29+
else{
30+
cb();
31+
}
32+
}
33+
34+
function execute(cmd, cb){
1435

1536
exec(cmd, function (err, stdout, stderr) {
1637
if(err){
@@ -19,12 +40,12 @@ function run(cmd, onClose){
1940
throw err;
2041
}
2142
console.log(stdout);
22-
onClose();
43+
cb();
2344
});
2445
}
2546

2647
function build(cb) {
27-
run('tsc', cb)
48+
run('node', [tsc], cb);
2849
}
2950

3051
function clean(cb) {
@@ -34,7 +55,7 @@ function clean(cb) {
3455
}
3556

3657
function webpack(cb){
37-
run('webpack --config ./webpack.config.js', cb);
58+
run('node', [wp, '--config', './webpack.config.js'], cb);
3859
}
3960

4061
function copy(cb) {
@@ -43,7 +64,7 @@ function copy(cb) {
4364
}
4465

4566
function pack(cb){
46-
run('npm pack', cb);
67+
execute('npm pack', cb);
4768
}
4869

4970
exports.build = build;

‎package-lock.json

+866-61
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
"main": "dist/grid.js",
66
"types": "ts-react-json-table.d.ts",
77
"scripts": {
8-
"build": "tsc"
8+
"build": "tsc",
9+
"webpack": "gulp webpack",
10+
"pack": "gulp pack"
911
},
1012
"repository": {
1113
"type": "git",
@@ -25,10 +27,10 @@
2527
"devDependencies": {
2628
"@types/node": "^22.13.4",
2729
"@types/react": "^19.0.9",
28-
"gulp": "^5.0.0",
2930
"chalk": "^4.1.2",
31+
"gulp": "^5.0.0",
3032
"typescript": "^5.7.3",
31-
"webpack": "^5.98.0"
33+
"webpack-cli": "^6.0.1"
3234
},
3335
"dependencies": {
3436
"react": "^19.0.0"

0 commit comments

Comments
 (0)
Please sign in to comment.