Skip to content

Commit

Permalink
Beginning CLI tool and able to read files at a path
Browse files Browse the repository at this point in the history
  • Loading branch information
vzhang03 committed Jul 11, 2024
1 parent 77d0eed commit f7530bc
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/tutorials/metadata-tutorial.md
Original file line number Diff line number Diff line change
@@ -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
31 changes: 31 additions & 0 deletions packages/metadata/cli/cli.js
Original file line number Diff line number Diff line change
@@ -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());
22 changes: 22 additions & 0 deletions packages/metadata/cli/test/bob.txt
Original file line number Diff line number Diff line change
@@ -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());
8 changes: 8 additions & 0 deletions packages/metadata/cli/test/joe.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f7530bc

Please sign in to comment.