mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
ui build
This commit is contained in:
1 parent
9c45527522
commit
7dc31d02fa
15 files changed
+10521
-3
No files matched your search
@@ -0,0 +1,35 @@
|
||||
/* eslint-disable */
|
||||
import PluginError from 'plugin-error';
|
||||
import through from 'through2';
|
||||
import fs from 'fs-extra';
|
||||
|
||||
export default function touch(mtime) {
|
||||
async function touchFile(file) {
|
||||
const fd = await fs.open(file.path, 'a');
|
||||
try {
|
||||
await fs.futimes(fd, mtime, mtime);
|
||||
} finally {
|
||||
await fs.close(fd);
|
||||
}
|
||||
}
|
||||
|
||||
function processStream(file, encoding, callback) {
|
||||
if (file.isNull()) {
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
if (file.isStream()) {
|
||||
this.emit('error', new PluginError('gulpTouch', 'Stream not supported'));
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
touchFile(file)
|
||||
.catch(err => this.emit('error', err))
|
||||
.then(() => {
|
||||
this.push(file);
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
return through.obj(processStream);
|
||||
}
|
||||
Reference in new issue
Block a user