File tree 2 files changed +30
-1
lines changed
2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
10
10
11
11
For a steady stream of TILs, [ sign up for my newsletter] ( https://crafty-builder-6996.ck.page/e169c61186 ) .
12
12
13
- _ 1231 TILs and counting..._
13
+ _ 1232 TILs and counting..._
14
14
15
15
---
16
16
@@ -432,6 +432,7 @@ _1231 TILs and counting..._
432
432
- [ Object Initialization With Shorthand Property Names] ( javascript/object-initialization-with-shorthand-property-names.md )
433
433
- [ Obtain Undefined Value With The Void Operator] ( javascript/obtain-undefined-value-with-the-void-operator.md )
434
434
- [ Parse A Date From A Timestamp] ( javascript/parse-a-date-from-a-timestamp.md )
435
+ - [ Pre And Post Hooks For Yarn Scripts] ( javascript/pre-and-post-hooks-for-yarn-scripts.md )
435
436
- [ Purge Null And Undefined Values From Object] ( javascript/purge-null-and-undefined-values-from-object.md )
436
437
- [ Random Cannot Be Seeded] ( javascript/random-cannot-be-seeded.md )
437
438
- [ Reach Into An Object For Nested Data With Get] ( javascript/reach-into-an-object-for-nested-data-with-get.md )
Original file line number Diff line number Diff line change
1
+ # Pre And Post Hooks For Yarn Scripts
2
+
3
+ In [ yarn] ( https://classic.yarnpkg.com/ ) v1, there is a special syntax for
4
+ script names that allows you to define pre and post hooks.
5
+
6
+ For instance, if you have a ` build ` script, you can define a ` prebuild ` and/or
7
+ a ` postbuild ` script as well. Then, anytime you invoke ` yarn build ` , the
8
+ ` prebuild ` script will be automatically run before ` build ` and the ` postbuild `
9
+ script be automatically run after ` build ` .
10
+
11
+ This ` pre{script} ` and ` post{script} ` syntax works for any script.
12
+
13
+ ``` json
14
+ {
15
+ "scripts" : {
16
+ "predeploy" : " node pre-deploy-steps"
17
+ "deploy" : " my-framework deploy" ,
18
+ "postdeploy" : " node post-deploy-steps"
19
+ }
20
+ }
21
+ ```
22
+
23
+ This syntax may lead to unexpected script invocations. For instance, a
24
+ ` preserve ` script will run ahead of a ` serve ` script even though those were
25
+ probably intended to be unrelated scripts. This is, in part, why this syntax is
26
+ no longer support in yarn v2.
27
+
28
+ [ source] ( https://classic.yarnpkg.com/lang/en/docs/cli/run/#toc-yarn-run-script )
You can’t perform that action at this time.
0 commit comments