Skip to content

Commit fcbf8b1

Browse files
init [skip ci]
0 parents  commit fcbf8b1

File tree

10 files changed

+122
-0
lines changed

10 files changed

+122
-0
lines changed

.codecrafters/compile.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
#
3+
# This script is used to compile your program on CodeCrafters
4+
#
5+
# This runs before .codecrafters/run.sh
6+
#
7+
# Learn more: https://codecrafters.io/program-interface
8+
9+
# (This file is empty since Javascript programs don't use a compile step)

.codecrafters/run.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
#
3+
# This script is used to run your program on CodeCrafters
4+
#
5+
# This runs after .codecrafters/compile.sh
6+
#
7+
# Learn more: https://codecrafters.io/program-interface
8+
9+
# Exit early if any commands fail
10+
set -e
11+
12+
exec node app/main.js "$@"

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[![progress-banner](https://backend.codecrafters.io/progress/shell/0c0cbf1b-4741-484b-bc0f-b33b9f9b3a48)](https://app.codecrafters.io/users/codecrafters-bot?r=2qF)
2+
3+
This is a starting point for JavaScript solutions to the
4+
["Build Your Own Shell" Challenge](https://app.codecrafters.io/courses/shell/overview).
5+
6+
In this challenge, you'll build your own POSIX compliant shell that's capable of
7+
interpreting shell commands, running external programs and builtin commands like
8+
cd, pwd, echo and more. Along the way, you'll learn about shell command parsing,
9+
REPLs, builtin commands, and more.
10+
11+
**Note**: If you're viewing this repo on GitHub, head over to
12+
[codecrafters.io](https://codecrafters.io) to try the challenge.
13+
14+
# Passing the first stage
15+
16+
The entry point for your `shell` implementation is in `app/main.js`. Study and
17+
uncomment the relevant code, and push your changes to pass the first stage:
18+
19+
```sh
20+
git commit -am "pass 1st stage" # any msg
21+
git push origin master
22+
```
23+
24+
Time to move on to the next stage!
25+
26+
# Stage 2 & beyond
27+
28+
Note: This section is for stages 2 and beyond.
29+
30+
1. Ensure you have `node (21)` installed locally
31+
1. Run `./your_program.sh` to run your program, which is implemented in
32+
`app/main.js`.
33+
1. Commit your changes and run `git push origin master` to submit your solution
34+
to CodeCrafters. Test output will be streamed to your terminal.

app/main.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const readline = require("readline");
2+
3+
const rl = readline.createInterface({
4+
input: process.stdin,
5+
output: process.stdout,
6+
});
7+
8+
// Uncomment this block to pass the first stage
9+
// rl.question("$ ", (answer) => {
10+
// rl.close();
11+
// });

codecrafters.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Set this to true if you want debug logs.
2+
#
3+
# These can be VERY verbose, so we suggest turning them off
4+
# unless you really need them.
5+
debug: false
6+
7+
# Use this to change the JavaScript version used to run your code
8+
# on Codecrafters.
9+
#
10+
# Available versions: nodejs-21
11+
language_pack: nodejs-21

package-lock.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "@codecrafters/build-your-own-shell",
3+
"version": "1.0.0",
4+
"description": "Build your own Shell challenge, from CodeCrafters",
5+
"main": "main.js",
6+
"scripts": {
7+
"dev": "node app/main.js"
8+
},
9+
"keywords": [
10+
"build-your-own-x"
11+
],
12+
"author": "",
13+
"license": "MIT",
14+
"dependencies": {}
15+
}

your_program.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
#
3+
# Use this script to run your program LOCALLY.
4+
#
5+
# Note: Changing this script WILL NOT affect how CodeCrafters runs your program.
6+
#
7+
# Learn more: https://codecrafters.io/program-interface
8+
9+
set -e # Exit early if any commands fail
10+
11+
# Copied from .codecrafters/run.sh
12+
#
13+
# - Edit this to change how your program runs locally
14+
# - Edit .codecrafters/run.sh to change how your program runs remotely
15+
exec node app/main.js "$@"

0 commit comments

Comments
 (0)