PlainNotebook
"PlainNotebook" is used for managing files without file extensions (such as .env, .gitignore, etc.)
We are not liable for anything you edit or manage maliciously. Be careful when editing certain files such as .env.
Usage
Setup
const Nodebook = require('nodejs-notebook');
const gitignore = new Nodebook.PlainNotebook('.gitignore');fileName(options)
object options:
options.lower- Whether or not the name should be turned to lower case.
Return: The file name.
gitignore.fileName({ lower: false });
// returns ".gitignore"resetFile()
Resets the file.
gitignore.resetFile();
// resets .gitignoredeleteFile(delay)
Deletes the file
number delay: Sets how many seconds before deleting the file.
gitignore.deleteFile();
// Deletes the file instantly
gitignore.deleteFile(10);
// Deletes the file in 10 secondsfetchLine(line)
Fetches an existing line's content.
number line: The line number to get the information from.
gitignore.fetchLine(3);
// fetches the third line
gitignore.fetchLine(10);
// fetches the tenth lineReturn: The line content.
deleteLine(line)
Sets an existing line in the file to empty.
number line: The line number to make empty.
gitignore.deleteLine(15);
// sets the fifteenth line emptyeditLine(line, key)
Replaces an existing line with a new string.
number line: The line number to set it to.
string key: The string that will replace the line.
gitignore.editLine(1, 'node_modules/');
// sets the first line to 'node_modules/'addLine(key)
Adds a string at the next available line in the file.
string key: The string to add at the next available line.
gitignore.addLine('package-lock.json');
// adds 'Yippi Ki Yay!' to the next linecontent()
Returns the file's content into a string.
console.log(gitignore.content());
// should log the file's contentLast updated
Was this helpful?