file.js 641 B

1234567891011121314151617181920212223242526272829303132333435
  1. 'use strict';
  2. const { readFile, readFileSync, stat, statSync } = require('hexo-fs');
  3. class File {
  4. constructor({ source, path, params, type }) {
  5. this.source = source;
  6. this.path = path;
  7. this.params = params;
  8. this.type = type;
  9. }
  10. read(options) {
  11. return readFile(this.source, options);
  12. }
  13. readSync(options) {
  14. return readFileSync(this.source, options);
  15. }
  16. stat(options) {
  17. return stat(this.source);
  18. }
  19. statSync(options) {
  20. return statSync(this.source);
  21. }
  22. }
  23. File.TYPE_CREATE = 'create';
  24. File.TYPE_UPDATE = 'update';
  25. File.TYPE_SKIP = 'skip';
  26. File.TYPE_DELETE = 'delete';
  27. module.exports = File;