doomemacs/modules/lang/javascript/autoload.el

17 lines
688 B
EmacsLisp
Raw Normal View History

2017-02-19 18:57:16 -05:00
;;; lang/javascript/autoload.el
2017-03-02 18:20:46 -05:00
(defvar +javascript-npm-conf (make-hash-table :test 'equal))
;;;###autoload
(defun +javascript-npm-conf (&optional project-root refresh-p)
"Retrieves an alist of this project's 'package.json'. If REFRESH-P is non-nil
ignore the cache."
(let ((project-root (or project-root (doom-project-root))))
(or (and (not refresh-p)
(gethash project-root +javascript-npm-conf))
(let ((package-file (expand-file-name "package.json" project-root)))
(when-let (json (and (file-exists-p package-file)
(json-read-file package-file)))
(puthash project-root json +javascript-npm-conf))))))