mirror of
https://github.com/jspsych/jsPsych.git
synced 2025-05-10 19:20:55 +00:00
Beginning CLI tool and able to read files at a path
This commit is contained in:
parent
77d0eedebd
commit
f7530bcce5
8
docs/tutorials/metadata-tutorial.md
Normal file
8
docs/tutorials/metadata-tutorial.md
Normal 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
|
31
packages/metadata/cli/cli.js
Normal file
31
packages/metadata/cli/cli.js
Normal 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());
|
22
packages/metadata/cli/test/bob.txt
Normal file
22
packages/metadata/cli/test/bob.txt
Normal 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());
|
8
packages/metadata/cli/test/joe.txt
Normal file
8
packages/metadata/cli/test/joe.txt
Normal 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
|
Loading…
Reference in New Issue
Block a user