Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

splits cards.csv into separate files; loads from these on seed:db #36

Merged
merged 1 commit into from
Dec 1, 2020

Conversation

sbenthall
Copy link
Contributor

Addresses #35

I am having a hard time figuring out if this script works.

When I run yarn seed:db with this change, I get the following command line output:

$ yarn seed:db
yarn run v1.22.5
$ node ./bin/seed-db.js
$ node ./bin/seed-deck.js -p assets/decks/chaos -n Chaos -d 'Graphically stunning, gentle'
$ node ./bin/seed-deck.js -p assets/decks/jung -n Jung -d 'Deeply psychological'
$ node ./bin/seed-deck.js -p assets/decks/toth -n Toth -d 'Beautiful, unsettling, powerful'
$ node ./bin/seed-deck.js -p assets/decks/riderwaite -n RiderWaite -d 'Classical, fairy-tale-like'
$ node ./bin/seed-deck.js -p assets/decks/yrevocnu -n Yrevocnu -d 'Maximum Viable Tarot'
[1606515975744] INFO  (7841 on nothingness): STATUS: MONGO READY @ mongodb://localhost:27017/pgbg
[1606515975745] INFO  (7859 on nothingness): STATUS: MONGO READY @ mongodb://localhost:27017/pgbg
[1606515975749] INFO  (7840 on nothingness): STATUS: MONGO READY @ mongodb://localhost:27017/pgbg
[1606515975815] INFO  (7887 on nothingness): STATUS: MONGO READY @ mongodb://localhost:27017/pgbg
[1606515975858] INFO  (7875 on nothingness): STATUS: MONGO READY @ mongodb://localhost:27017/pgbg

And then the process hangs.

I suspect the may be an unresolved promise in each one of the calls to seed-deck.js? But I don't know what it could be or how to debug this kind of problem.

I have tried replacing the path to the csv files with './' + program.path + '.csv' (instead of program.path + '.csv', which is closer to the original construction) but it does not improve the situation.

@sbenthall
Copy link
Contributor Author

Error was in unreplaced files -> image_files in console.log statement at the end of the script.

@sbenthall
Copy link
Contributor Author

Fix has been pushed.
Commits have been squashed with git rebase.

bin/seed-deck.js Outdated
@@ -12,17 +12,17 @@ program
.option('-d, --description <string>', 'deck description')
.parse(process.argv);

const files = fs.readdirSync(program.path);
const image_files = fs.readdirSync(program.path);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: imageFiles for following JS conventions

bin/seed-deck.js Outdated

console.log(`Upserted ${files.length} cards in "${program.name}"`);
process.exit();
console.log(`Upserted ${image_files.length} cards in "${program.name}"`);
})();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: newline at end of file to pass .eslint rules (if we don't have that rule, we should add it)

@sbenthall
Copy link
Contributor Author

Thank you so much @benheller
I will fix the nits, rebase fixup them into one commit, then merge

@sbenthall
Copy link
Contributor Author

Out of curiosity, do you know why the yarn process does not exit and return to the command line?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants