Skip to content

Commit

Permalink
Add command pkg-file
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Mar 20, 2022
1 parent 998117a commit e267b5a
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 9 deletions.
29 changes: 29 additions & 0 deletions cmds/pkg-file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Copyright (C) 2022 Jen-Chieh Shen
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Emacs; see the file COPYING. If not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/

"use strict";

const util = require("../src/util");

exports.command = "pkg-file";
exports.desc = "generate -pkg file";

exports.handler = async ({ }) => {
await util.e_call('pkg-file');
};
16 changes: 8 additions & 8 deletions lisp/_prepare.el
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
(require 'rect)
(require 'subr-x)

(setq package-enable-at-startup nil ; To avoid initializing twice
package-check-signature nil)

(setq package-archives nil ; Leave it to custom use
package-archive-priorities nil)
(unless (bound-and-true-p eask--initialized-p)
(setq package-enable-at-startup nil ; To avoid initializing twice
package-check-signature nil
package-archives nil ; Leave it to custom use
package-archive-priorities nil))

(defcustom eask-path-ignores
(append project-vc-ignores '(".eask"))
Expand Down Expand Up @@ -102,7 +102,7 @@ the `eask-start' execution.")
"Is non-nil if .eask does not exists; meaning users haven't called eask in the
current workspace.")

(defvar eask--setup-done-p nil
(defvar eask--initialized-p nil
"Set to t once the environment setup has done; this is used when calling
other scripts internally. See function `eask-call'.")

Expand Down Expand Up @@ -174,8 +174,8 @@ Eask file in the workspace."
(run-hooks 'eask-before-command-hook)
(run-hooks (intern (concat "eask-before-command-" (eask-command) "-hook")))
;; set it locally, else we ignore to respect default settings
(if (or (eask-global-p) eask--setup-done-p) (progn ,@body)
(let* ((eask--setup-done-p t)
(if (or (eask-global-p) eask--initialized-p) (progn ,@body)
(let* ((eask--initialized-p t)
(user-emacs-directory (expand-file-name (concat ".eask/" emacs-version "/")))
(package-user-dir (expand-file-name "elpa" user-emacs-directory))
(eask--first-init-p (not (file-directory-p user-emacs-directory)))
Expand Down
3 changes: 2 additions & 1 deletion lisp/autoloads.el
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@

(eask-start
(package-generate-autoloads
(or (eask-package-get :name) (file-name-sans-extension eask-package-file))
(or (eask-package-get :name)
(file-name-nondirectory (file-name-sans-extension eask-package-file)))
default-directory))

;;; autoloads.el ends here
31 changes: 31 additions & 0 deletions lisp/pkg-file.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
;;; pkg-file.el --- Generate -pkg file -*- lexical-binding: t; -*-

;;; Commentary:
;;
;; Command use generate -pkg file,
;;
;; $ eask pkg-file
;;

;;; Code:

(load-file (expand-file-name
"_prepare.el"
(file-name-directory (nth 1 (member "-scriptload" command-line-args)))))

(eask-start
(eask-call "install") ; XXX maybe try to avoid this?

(let* ((name (or (eask-package-get :name)
(file-name-nondirectory (file-name-sans-extension eask-package-file))))
(dir (file-name-directory (locate-library name)))
(pkg-file (concat name "-pkg.el"))
(gen-filename (concat dir pkg-file)))
(write-region (with-temp-buffer
(insert-file-contents gen-filename)
(buffer-string))
nil pkg-file)
(message "")
(message "Write file %s..." gen-filename)))

;;; pkg-file.el ends here

0 comments on commit e267b5a

Please sign in to comment.