Beginning CLI tool and able to read files at a path

This commit is contained in:
vzhang03 2024-07-11 16:16:28 -04:00
parent 77d0eedebd
commit f7530bcce5
4 changed files with 69 additions and 0 deletions

View File

@ -0,0 +1,8 @@
# jsPsych "metadata" experimen
What does metadata do and what is the importance of it
## Choose your own (setup) adventure
Starting with the release of version 7.0 of jsPsych there are three different ways that you can add jsPsych to your project.
Which approach you choose will depend on what your goals are.t

View File

@ -0,0 +1,31 @@
import fs from "fs";
import path from "path";
import JsPsychMetadata from "../dist/index.js";
const metadata = new JsPsychMetadata();
const directoryPath = process.cwd() + "/test"; // can make this the path that is given (relative)
console.log(directoryPath);
fs.readdir(directoryPath, (err, files) => {
if (err) {
console.error("Error reading directory:", err);
return;
}
files.forEach((file) => {
const filePath = path.join(directoryPath, file);
// Read each file asynchronously
fs.readFile(filePath, "utf8", (err, data) => {
if (err) {
console.error(`Error reading file ${file}:`, err);
return;
}
console.log(`Contents of ${file}:`);
console.log(data); // Output the contents of the file
});
});
});
// console.log("metadata:", metadata.getMetadata());

View File

@ -0,0 +1,22 @@
import JsPsychMetadata from '../dist/index.js';
import fs from 'fs';
import path from 'path';
const metadata = new JsPsychMetadata();
const directoryPath = './test';
fs.readdir(directoryPath, (err, files) => {
if (err) {
console.error('Error reading directory:', err);
return;
}
console.log(`Files in ${directoryPath}:`);
files.forEach(file => {
console.log(file);
});
});
console.log("metadata:", metadata.getMetadata());

View File

@ -0,0 +1,8 @@
# jsPsych "metadata" experimen
What does metadata do and what is the importance of it
## Choose your own (setup) adventure
Starting with the release of version 7.0 of jsPsych there are three different ways that you can add jsPsych to your project.
Which approach you choose will depend on what your goals are.t