content
String
The text content of the file, interpreted as UTF-8.
When set, the value is serialized using
Throws if the file doesn't exist.
When set, the value is serialized using
JSON.stringify()
if it isn't already a string.Throws if the file doesn't exist.
Count the lines in a text file
const readmeContent = here.file('README.md').content;
const readmeLineCount = readmeContent.split('\n').length;
cli.tell(`The readme file has ${format.number.integer(readmeLineCount, 'line')}.`);
Write JSON to a file
const basicInfo = {
name: await cli.ask('Project name?'),
description: await cli.ask('Project description?')
};
here.file('package.json').make().content = basicInfo;