mirror of
https://github.com/penpot/penpot.git
synced 2025-06-06 21:21:37 +02:00
✨ Improve text shape tracing process on exporter.
Fixes many bugs related to the svgo removal and remove unneded neesting of groups.
This commit is contained in:
parent
b1477d8087
commit
c447279c75
4 changed files with 215 additions and 148 deletions
71
exporter/src/app/util/shell.cljs
Normal file
71
exporter/src/app/util/shell.cljs
Normal file
|
@ -0,0 +1,71 @@
|
|||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||
;; defined by the Mozilla Public License, v. 2.0.
|
||||
;;
|
||||
;; Copyright (c) UXBOX Labs SL
|
||||
|
||||
(ns app.util.shell
|
||||
"Shell & FS utilities."
|
||||
(:require
|
||||
["child_process" :as chp]
|
||||
["fs" :as fs]
|
||||
["os" :as os]
|
||||
["path" :as path]
|
||||
[lambdaisland.glogi :as log]
|
||||
[promesa.core :as p]))
|
||||
|
||||
(log/set-level "app.util.shell" :trace)
|
||||
|
||||
(defn create-tmpdir!
|
||||
[prefix]
|
||||
(p/create
|
||||
(fn [resolve reject]
|
||||
(fs/mkdtemp (path/join (os/tmpdir) prefix)
|
||||
(fn [err dir]
|
||||
(if err
|
||||
(reject err)
|
||||
(resolve dir)))))))
|
||||
|
||||
(defn write-file!
|
||||
[fpath content]
|
||||
(p/create
|
||||
(fn [resolve reject]
|
||||
(fs/writeFile fpath content (fn [err]
|
||||
(if err
|
||||
(reject err)
|
||||
(resolve nil)))))))
|
||||
(defn read-file
|
||||
[fpath]
|
||||
(p/create
|
||||
(fn [resolve reject]
|
||||
(fs/readFile fpath (fn [err content]
|
||||
(if err
|
||||
(reject err)
|
||||
(resolve content)))))))
|
||||
|
||||
(defn run-cmd!
|
||||
[cmd]
|
||||
(p/create
|
||||
(fn [resolve reject]
|
||||
(log/trace :fn :run-cmd :cmd cmd)
|
||||
(chp/exec cmd #js {:encoding "buffer"}
|
||||
(fn [error stdout stderr]
|
||||
;; (log/trace :fn :run-cmd :stdout stdout)
|
||||
(if error
|
||||
(reject error)
|
||||
(resolve stdout)))))))
|
||||
|
||||
(defn rmdir!
|
||||
[path]
|
||||
(p/create
|
||||
(fn [resolve reject]
|
||||
(fs/rmdir path #js {:recursive true}
|
||||
(fn [err]
|
||||
(if err
|
||||
(reject err)
|
||||
(resolve nil)))))))
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue