Function: projectile--npm-workspace-patterns

projectile--npm-workspace-patterns is a byte-compiled function defined in projectile.el.

Signature

(projectile--npm-workspace-patterns FILE)

Documentation

Return the workspaces globs declared by the package.json at FILE.

Both the plain array form and the {"packages": [...]} form yarn uses are understood.

Source Code

;; Defined in ~/.emacs.d/elpa/projectile-20260820.1509/projectile.el
(defun projectile--npm-workspace-patterns (file)
  "Return the `workspaces' globs declared by the package.json at FILE.
Both the plain array form and the `{\"packages\": [...]}' form yarn uses
are understood."
  (when (fboundp 'json-parse-string)
    (let* ((json (ignore-errors
                   (json-parse-string (projectile--file-contents file)
                                      :object-type 'alist
                                      :array-type 'list)))
           (workspaces (alist-get 'workspaces json)))
      (cond
       ((and (listp workspaces) (stringp (car workspaces))) workspaces)
       ((listp workspaces) (alist-get 'packages workspaces))))))