Copy import { fs } from '@empathize/framework';
// print 'my_file.txt' content to the console
fs.read('my_file.txt').then(console.log);
Copy import { fs } from '@empathize/framework';
// Write 'Hello, World!' to 'my_file.txt'
fs.write('my_file.txt', 'Hello, World!');
Copy import { fs } from '@empathize/framework';
// Check if 'my_file.txt' exists
fs.exists('my_file.txt').then(console.log);
Copy import { fs } from '@empathize/framework';
// Get 'my_file.txt' file stats
fs.stats('my_file.txt').then((stats) => {
console.log(`Type: ${stats.type}`); // will be 'file' or 'directory'
console.log(`Size: ${stats.size} bytes`);
});
Copy import { fs } from '@empathize/framework';
// Remove 'my_file.txt'
fs.remove('my_file.txt');
// Remove 'my_folder'
fs.remove('my_folder');
Copy import { fs } from '@empathize/framework';
// List files and folders inside of the 'my_folder'
fs.files('my_folder').then((files) => {
for (const file of files)
console.log(`[${file.type}] my_folder/${file.name}`);
});
Copy import { fs } from '@empathize/framework';
// Create 'my_folder_1/my_folder_2' directory (recursively)
fs.mkdir('my_folder_1/my_folder_2');
Copy import { fs } from '@empathize/framework';
// Copy 'from/my_file.txt' as 'to/my_file.txt'
fs.copy('from/my_file.txt', 'to/my_file.txt');
// Copy 'from/my_folder' as 'to/my_folder'
fs.copy('from/my_folder', 'to/my_folder');
Copy import { fs } from '@empathize/framework';
// Move 'from/my_file.txt' as 'to/my_file.txt'
fs.move('from/my_file.txt', 'to/my_file.txt');
// Move 'from/my_folder' as 'to/my_folder'
fs.move('from/my_folder', 'to/my_folder');