{"record":{"id":"d8bef89239fc309f","repo":"HandyOrg/HandyControl","slug":"include-file-empty","errorCode":null,"errorMessage":"Include file empty.","messagePattern":"Include file empty\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"doc/themes/next/scripts/tags/include-raw.js","lineNumber":22,"sourceCode":"\n/* global hexo */\n\n'use strict';\n\nvar pathFn = require('path');\nvar fs = require('hexo-fs');\n\nfunction includeRaw(args) {\n  var path = pathFn.join(hexo.source_dir, args[0]);\n\n  return fs.exists(path).then(function(exist) {\n    if (!exist) {\n      hexo.log.error('Include file not found!');\n      return;\n    }\n    return fs.readFile(path).then(function(contents) {\n      if (!contents) {\n        hexo.log.warn('Include file empty.');\n        return;\n      }\n      return contents;\n    });\n  });\n}\n\nhexo.extend.tag.register('include_raw', includeRaw, {ends: false, async: true});\n","sourceCodeStart":4,"sourceCodeEnd":31,"githubUrl":"https://github.com/HandyOrg/HandyControl/blob/2c0875ebd67326e0c67282967e3e809c69282fee/doc/themes/next/scripts/tags/include-raw.js#L4-L31","documentation":"The NexT theme's include-raw Hexo tag reads a file and logs a warning when fs.readFile returns empty/null contents. The file exists (the not-found branch already returned), but it has zero bytes, so nothing is included in the rendered output. Non-fatal: the tag simply returns nothing.","triggerScenarios":"{% include-raw path %} where the referenced file exists on disk but is completely empty (0 bytes), so contents is falsy in the readFile then-callback.","commonSituations":"An empty placeholder file committed to the repo, a build/export step that truncated the file, or a shared code snippet file that was emptied during a refactor.","solutions":["Put the intended content into the referenced file.","Verify the resolved path points to the file you meant (an empty unintended file may shadow the real one).","If an empty file is intentional, ignore the warning or populate a minimal placeholder."],"exampleFix":"// before\n{% include-raw lang:javascript %}   // scripts/demo.js exists but is 0 bytes\n// after\n// add content to scripts/demo.js, e.g.:\n// console.log('demo');\n{% include-raw lang:javascript %}","handlingStrategy":"validation","validationCode":"const fs = require('fs');\nfunction canIncludeRaw(p) {\n  if (!fs.existsSync(p)) { console.error('include-raw: file not found: ' + p); return false; }\n  if (fs.statSync(p).size === 0) { console.warn('include-raw: file is empty: ' + p); return false; }\n  return true;\n}","typeGuard":"function isNonEmptyFile(stat) {\n  return stat && stat.isFile() && stat.size > 0;\n}","tryCatchPattern":null,"preventionTips":["Check file size > 0 for every file referenced by {% include-raw %} before building.","Use paths relative to the source directory consistently to avoid including an unintended empty file.","Add a CI step that fails the build when included snippet files are empty."],"tags":["hexo","theme","empty-file","file-read"],"backgroundTag":"file-read-failed","analyzedSha":"2c0875ebd67326e0c67282967e3e809c69282fee","analyzedAt":"2026-09-14T14:45:29.754Z","contentChangedAt":"2026-09-14T14:45:29.754Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}