2
2
Exercises taken from the Leetcode 75 interview problem compilation. Each exercise folder has the
3
3
following files:
4
4
``` sh
5
- $ tree 283-move-zeroes
6
- 283-move-zeroes # Exercise name
5
+ $ tree , < exercise-name >
6
+ , < exercise- name>
7
7
├── index.js # Solution implementation
8
8
├── package.json # Contains execution scripts
9
9
├── README.md # Problem description
10
10
└── test.js # Test cases implementation
11
11
12
12
```
13
13
14
- ## ` package.json ` scripts
15
- You can use the following scripts on each exercise:
14
+ ## Usage
15
+ To streamline the setup process for each exercise, you can automatically inject the common scripts
16
+ defined in ` leetcode-node-scripts.json ` into the ` package.json ` of each exercise directory using the
17
+ ` add-scripts.sh ` bash script.
18
+
19
+ ### Injecting Scripts Automatically
20
+ 1 . Ensure you have a ` package.json ` file in your exercise directory (create one with ` npm init -y `
21
+ if necessary).
22
+ 2 . Use the ` add-scripts.sh ` script to inject the scripts from ` leetcode-node-scripts.json ` into your
23
+ ` package.json ` :
24
+
25
+ ``` sh
26
+ # Execute from the repository root
27
+ $ ./add-scripts.sh < path-to-exercise> /package.json
28
+
29
+ ```
30
+
31
+ After running the script, your package.json will include the following scripts from
32
+ ` leetcode-node-scripts.json ` :
16
33
``` json
17
- // leetcode-node-scripts.json
18
34
{
19
35
"start" : " node index.js" ,
20
36
"debug" : " node --inspect-brk index.js" ,
@@ -23,16 +39,10 @@ You can use the following scripts on each exercise:
23
39
24
40
```
25
41
26
- Where:
27
- - ` start ` : Starts the program
28
- - ` debug ` : Starts the program in debug mode
29
- - ` test ` : Run the test suite for this exercise
30
-
31
- ### Populating Automatically the ` scripts ` Key of ` package.json ` files
32
- Execute the following script, in this example the ` package.json ` file has been created beforehand
33
- inside the directory ` ./1004-max-consecutive-ones-iii ` using ` npm init -y ` :
34
- ``` sh
35
- # Execute from the repository root
36
- $ ./add-scripts.sh ./1004-max-consecutive-ones-iii/package.json
37
-
38
- ```
42
+ ### Understanding the Scripts
43
+ - ` start ` : Runs the ` index.js ` file to start the program. Use this when you want to run you
44
+ solution.
45
+ - ` debug ` : Starts the program in debug mode with ` --inspect-brk ` , allowing you to attach a debugger
46
+ and step through the code.
47
+ - ` test ` : Runs the ` test.js ` file to execute all test cases associated with the exercise, ensuring
48
+ your solution meets the specified requirements.
0 commit comments