UNPKG

source-line-processor

Version:

`source-line-processor script.js --dir $PWD/test --dry-run --pattern "*.js"`

78 lines (62 loc) 1.38 kB
import File from '../File'; import { TodoFormat, build, parse } from './parser'; export { default as find } from './find'; class Todo { private _file: File; private _todo: TodoFormat | undefined; private _index: number; constructor(todo: TodoFormat, index: number, file: File) { this._file = file; this._index = index; this._todo = todo; } get owner() { return this._todo && this._todo.owner; } set owner(value: string | undefined) { if (this._todo) { this._todo.owner = value; this.update(); } } get content() { return this._todo && this._todo.content || ''; } set content(value: string) { if (this._todo) { this._todo.content = value; this.update(); } } get issueId() { return this._todo && this._todo.issueId; } set issueId(value: string | undefined) { if (this._todo) { this._todo.issueId = value; this.update(); } } get lineNUmber() { return this._index } get path() { return this._file.relativeLocation; } get raw() { return this._file.lines[this._index]; } set raw(string) { this._todo = parse(string); this.update(); } private update() { if (this._todo) { this._file.lines[this._index] = build(this._todo); } } remove() { this._todo = undefined; } } export default Todo;