js: npm dependency lookup; {expressjs,reactjs,electron,nodejs}-project-mode
This commit is contained in:
parent
cb13cb6e16
commit
90c0c0a517
1 changed files with 39 additions and 12 deletions
|
@ -109,22 +109,49 @@
|
||||||
(:leader :n "h" 'tide-documentation-at-point)))
|
(:leader :n "h" 'tide-documentation-at-point)))
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
(defvar npm-conf (make-hash-table :test 'equal))
|
||||||
(def-project-type! nodejs "node"
|
(def-project-type! nodejs "node"
|
||||||
:modes (web-mode js-mode js2-mode json-mode coffee-mode scss-mode sass-mode less-css-mode)
|
:modes (web-mode js-mode coffee-mode css-mode sass-mode pug-mode)
|
||||||
:files ("package.json"))
|
:files ("package.json")
|
||||||
|
:when
|
||||||
(def-project-type! angularjs "angular"
|
(lambda (&rest _)
|
||||||
:modes (web-mode js-mode js2-mode json-mode coffee-mode scss-mode sass-mode less-css-mode)
|
(let* ((project-path (narf/project-root))
|
||||||
:files ("public/libraries/angular/"))
|
(hash (gethash project-path npm-conf))
|
||||||
|
(package-file (f-expand "package.json" project-path))
|
||||||
(def-project-type! electron "electron"
|
deps)
|
||||||
:modes (nodejs-project-mode)
|
(awhen (and (not hash) (f-exists? package-file)
|
||||||
:files ("app/index.html" "app/main.js"))
|
(json-read-file package-file))
|
||||||
;; TODO electron-compile support
|
(puthash project-path it npm-conf)))
|
||||||
|
t))
|
||||||
|
|
||||||
(def-project-type! expressjs "express"
|
(def-project-type! expressjs "express"
|
||||||
|
:modes (nodejs-project-mode bower-project-mode)
|
||||||
|
:when
|
||||||
|
(lambda (&rest _)
|
||||||
|
(awhen (gethash (narf/project-root) npm-conf)
|
||||||
|
(assq 'express (cdr-safe (assq 'dependencies it))))))
|
||||||
|
|
||||||
|
;; TODO electron-compile support
|
||||||
|
(def-project-type! electron "electron"
|
||||||
:modes (nodejs-project-mode)
|
:modes (nodejs-project-mode)
|
||||||
:files ("node_modules/express/"))
|
:files ("app/index.html" "app/main.js")
|
||||||
|
:when
|
||||||
|
(lambda (&rest _)
|
||||||
|
(awhen (gethash (narf/project-root) npm-conf)
|
||||||
|
(let ((deps (append (car-safe (assq 'dependencies it))
|
||||||
|
(car-safe (assq 'devDependencies it)))))
|
||||||
|
(or (assq 'electron-prebuilt deps)
|
||||||
|
(assq 'electron-packager deps)
|
||||||
|
(string-prefix-p "electron" (or (assq 'start it) "") t))))))
|
||||||
|
|
||||||
|
(def-project-type! reactjs "react"
|
||||||
|
:modes (nodejs-project-mode bower-project-mode)
|
||||||
|
:when
|
||||||
|
(lambda (&rest _)
|
||||||
|
(let* ((project (narf/project-root))
|
||||||
|
(deps (append (cdr-safe (assq 'dependencies (gethash project bower-conf)))
|
||||||
|
(cdr-safe (assq 'dependencies (gethash project npm-conf))))))
|
||||||
|
(assq 'react deps))))
|
||||||
|
|
||||||
;; TODO react
|
;; TODO react
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue