-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathread-pkg.node.txt
47 lines (35 loc) · 2.27 KB
/
read-pkg.node.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
┏━━━━━━━━━━━━━━┓
┃ READ-PKG ┃
┗━━━━━━━━━━━━━━┛
ALTERNATIVES ==> #See pkg-dir doc
VERSION ==> #9.0.1
readPackage[Sync]([OPTS])->[>]OBJ #Read and parse PWD/package.json
#Throws if not found
parsePackage
(PACKAGE_OBJ, [OPTS])->OBJ #Same but only parses
OPTS.cwd #'PATH'|URL (def: process.cwd())
OPTS.normalize #BOOL (def: true): use `normalize-package-data`
┌─────────────────────┐
│ READ-PACKAGE-UP │
└─────────────────────┘
VERSION ==> #11.0.0
readPackageUp[Sync]([OPTS]) #Read and parse package.json (using `find-up` and `read-pkg`)
->[>]OBJ #OPTS: same as FIND-UP() + READ-PKG()
#Returns undefined if not found
#Returns OBJ:
# - packageJson PACKAGE
# - path 'PATH'
┌───────────────────┐
│ WRITE-PACKAGE │
└───────────────────┘
VERSION ==> #7.1.0
writePackage[Sync] #Write PACKAGE to PWD/package.json
(['PWD', ]PACKAGE[, OPTS])[->>] #Def 'PWD': '.'
#OPTS:
# - normalize BOOL (def: true): sort *dependencies alphabetically
# - indent STR|NUM (def: '\t')
updatePackage[Sync](...)[->>] #Same but update instead
addPackageDependencies[Sync]
(['PWD', ]OBJ[, OPTS])[->>] #Same but only for OBJ: [[dev|optional|peer]dependencies.]DEP 'VERSION'|BOOL
removePackageDependencies[Sync]
(['PWD', ]VAL[, OPTS])[->>] #Uses 'DEP'_ARR or OBJ: [dev|optional|peer]dependencies OBJ2|'DEP'_ARR