UNPKG

@tsed/cli

Version:
12 lines (11 loc) 348 B
export function insertImport(fileContent, content) { const lines = fileContent.split("\n"); const index = lines.findIndex((line) => { if (line.startsWith("#!")) { return false; } return !line.startsWith("import "); }); lines[index] = content + "\n" + lines[index]; return lines.join("\n"); }