runok
Version:
NPM scripts on steroids! Replace your scripts with pure JS
42 lines • 1.23 kB
TypeScript
import { TaskConfig } from '../task';
import { Result } from '../result';
interface writeToFileCallback {
(cfg: WriteToFileConfig): void;
}
/**
* Writes a data to file.
*
* Takes file name as first argument and config function as second.
*
* ```js
* writeToFile('blog-post.md', cfg => {
* cfg.line('---');
* cfg.line('title: My blogpost');
* cfg.line('---');
* cfg.line();
* cfg.textFromFile('blog-post.txt');
* cfg.text += '// copyright by me';
* });
* ```
*
* A second argument is a config function that passes in an object for text manipulation.
*
* ### Config API
*
* * `cfg.text` - string to be written to file
* * `cfg.textFromFile(file)` - loads a file and append its context to text
* * `cfg.line(text)` - appends a string to a text with "\n" after
* * `cfg.append(text)` - appends a string to a text
*/
export default function writeToFile(file: string, configFn: writeToFileCallback): Result;
declare class WriteToFileConfig extends TaskConfig {
TASK: string;
file: any;
text: any;
constructor(file: any);
textFromFile(file: string): void;
line(line: string): void;
append(text: string): void;
}
export {};
//# sourceMappingURL=writeToFile.d.ts.map