prompt-helper
Version:
A CLI tool to help you create and manage prompts for AI models.
76 lines • 2.52 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getExpectedHeader = getExpectedHeader;
// src/modules/headers/style.ts
const path_1 = __importDefault(require("path"));
/**
* Returns the expected comment-style file header for a given relative file path,
* based on its extension or known filename.
*
* @param relativePath - The relative file path from project root.
* @returns A header string (with comment syntax), or null if not applicable.
*/
function getExpectedHeader(relativePath) {
const basename = path_1.default.basename(relativePath);
const ext = path_1.default.extname(relativePath).toLowerCase();
// Special filenames without extensions
if (['Dockerfile', 'Makefile', 'CMakeLists.txt'].includes(basename)) {
return `# ${relativePath}`;
}
// Map extensions to comment styles: [prefix, suffix]
const styleMap = {
// JavaScript / TypeScript
'.ts': ['// ', ''],
'.tsx': ['// ', ''],
'.js': ['// ', ''],
'.jsx': ['// ', ''],
'.mjs': ['// ', ''],
// Compiled languages
'.go': ['// ', ''],
'.java': ['// ', ''],
'.cs': ['// ', ''],
'.cpp': ['// ', ''],
'.cc': ['// ', ''],
'.cxx': ['// ', ''],
'.c': ['// ', ''],
// JSON with comments
'.jsonc': ['// ', ''],
// Shell & scripting languages
'.sh': ['# ', ''],
'.bash': ['# ', ''],
'.zsh': ['# ', ''],
'.py': ['# ', ''],
'.rb': ['# ', ''],
'.pl': ['# ', ''],
'.tcl': ['# ', ''],
'.ps1': ['# ', ''],
// Windows batch
'.bat': ['REM ', ''],
'.cmd': ['REM ', ''],
// Stylesheets
'.css': ['/* ', ' */'],
'.scss': ['/* ', ' */'],
'.sass': ['/* ', ' */'],
'.less': ['/* ', ' */'],
// Markup & documentation
'.html': ['<!-- ', ' -->'],
'.htm': ['<!-- ', ' -->'],
'.xml': ['<!-- ', ' -->'],
'.md': ['<!-- ', ' -->'],
// Config files
'.yaml': ['# ', ''],
'.yml': ['# ', ''],
'.toml': ['# ', ''],
'.ini': ['; ', ''],
};
const style = styleMap[ext];
if (!style) {
return null;
}
const [prefix, suffix] = style;
return `${prefix}${relativePath}${suffix}`;
}
//# sourceMappingURL=style.js.map