Skip to content

Commit a9a7c85

Browse files
committed
trying gulp
1 parent c4997fe commit a9a7c85

File tree

4 files changed

+3811
-169
lines changed

4 files changed

+3811
-169
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,6 @@ dist
103103

104104
# TernJS port file
105105
.tern-port
106+
107+
108+
www

gulpfile.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import gulp from 'gulp';
2+
import { deleteAsync } from 'del';
3+
//const del = require('del');
4+
import { promises as fs } from 'fs';
5+
import path from 'path';
6+
7+
import replace from 'gulp-replace';
8+
9+
const dist_path = 'docs/.vitepress/dist';
10+
const www_path = 'www';
11+
12+
// Copy Job files
13+
async function copyDist() {
14+
// Clean destination folder
15+
await deleteAsync([path.join(www_path, 'dist/**/*')]);
16+
17+
// Ensure destination directory exists
18+
await fs.mkdir(path.join(www_path, 'dist'), { recursive: true });
19+
20+
return new Promise((resolve, reject) => {
21+
// Copy files from source to destination
22+
gulp.src(path.join(dist_path, '**', '*')) // Include all files and subfolders
23+
.pipe(gulp.dest(path.join(www_path, 'dist'))) // Destination folder
24+
.on('end', resolve) // Resolve the Promise when the task is complete
25+
.on('error', reject) // Reject the Promise if an error occurs
26+
.on('error', (err) => console.error('Error during copy:', err)); // Log errors
27+
});
28+
29+
}
30+
31+
function copyReplace() {
32+
return gulp.src(path.join(dist_path, '**', '*.*')) // Adjust the path to your directory and file types
33+
.pipe(replace(/\/comforthrmdocs\//g, (match) => {
34+
console.log(`Replaced: ${match}`); // Log every replacement
35+
return ''; // Replace with '/'
36+
}))
37+
.pipe(gulp.dest(path.join(www_path, 'dist'))); // Save the modified files to a 'dist' directory
38+
}
39+
40+
41+
// Define complex tasks
42+
const www = gulp.series(copyDist, copyReplace);
43+
44+
export { www }; // Export task so it can be run via npm

0 commit comments

Comments
 (0)