-
-
Notifications
You must be signed in to change notification settings - Fork 618
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
Add new exercise grep #752
Add new exercise grep #752
Conversation
Great question. From the canonical data:
I think we should actually create these files, instead of having them be generated by the tests. So, add For your second question, let's see if @tejasbubane agrees with this, I actually think it would be great if you make this script executable. That means, NO EXPORTS. I think we should do
Example:describe("tests something", () => {
it("works", () => {
const output = spawnSync('node', ['grep.js', '"Agamemnon"', 'iliad.txt'], { stdio: 'pipe' }).stdout.toString().trim()
expect(output).toBe("Of Atreus, Agamemnon, King of men.")
})
}) StubAdd the hashbang at the top so people can actually execute it on UNIX/POSIX environments: #!/usr/bin/env node We can even debate adding a "cross env" wrapper |
Alright, I didn't know about |
8df9796
to
9340480
Compare
The MVP is working, i'll finish this ASAP :) |
So i got a problem because the test script only copies the |
Yes! Let's add them. If you look at this code: https://github.com/exercism/javascript/blob/master/scripts/helpers.js#L74-L77 const libDir = ['exercises', assignment, 'lib'].join('/');
if(shell.test('-d', libDir)) {
shell.cp(libDir + '/*.js', 'tmp_exercises/lib');
} ... you can see the const dataDir = ['exercises', assignment, 'data'].join('/');
if(shell.test('-d', dataDir)) {
shell.cp([dataDir, '*'].join('/'), 'tmp_exercises/data');
} |
Nice, should I add it myself ? |
Yes go ahead! |
5b38a17
to
5e8ff36
Compare
5e8ff36
to
f4d8a3e
Compare
Should I add stuff in the stub file ? Or should we let the user do the exercise from scratch ? Also should I write a README.md ? |
See CONTRIBUTING for the readme generation. You don't need to do this yourself. Let's add the stub file, but only have a comment with 'this is a stub blablabla' |
3c04284
to
0e871ec
Compare
If everything is ok, i can rebase my last 3 commits and we can merge this :) |
You don't need to rebase. I'll squash-merge |
Hi, do you have some time to merge it ? |
Co-Authored-By: Derk-Jan Karrenbeld <[email protected]>
This should be good now I think |
I like this exercise, I think it would make a great addition to explore JS more. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I absolutely love this exercise. Thank you so much for writing this @TomPradat
Fixes #737 .
I was wondering about the fact that this exercise is a CLI.
Unless I missed something, it's not possible to test a file that just executes a set of instructions.
I was thinking about exporting a function that takes the pattern, the files and options as arguments like that :
Is the user supposed to use the filesystem or should I provide him the data in the files in some way ?