Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions spork/sh.janet
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,11 @@
(if (= :windows (os/which))
(let [end (last (path/posix/parts src))
isdir (= (os/stat src :mode) :directory)]
(os/shell (string "C:\\Windows\\System32\\xcopy.exe"
" "
(path/win32/join ;(path/posix/parts src))
(path/win32/join ;(if isdir [;(path/posix/parts dest) end] (path/posix/parts dest)))
"/y /s /e /i > nul")))
(os/shell (string/join
["C:\\Windows\\System32\\xcopy.exe"
(path/win32/join ;(path/posix/parts src))
(path/win32/join ;(if isdir [;(path/posix/parts dest) end] (path/posix/parts dest)))
"/y /s /e /i /-i > nul"] " ")))
(os/execute ["cp" "-rf" src dest] :px)))

(def- shlex-grammar (peg/compile ~{:ws (set " \t\r\n")
Expand Down
14 changes: 12 additions & 2 deletions test/suite-sh.janet
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
(start-suite)

(def base-path "test")
(def assets-dir ["assets" "17"])

(do
(assert (deep= (os/dir (path/join base-path "assets/17"))
(assert (deep= (os/dir (path/join base-path ;assets-dir))
@["test.file"])
"test files are wrong, assets/17 should only contain test.file")
(sh/copy-file (path/join base-path "assets/17/test.file")
Expand Down Expand Up @@ -35,8 +36,17 @@
nil)
"sh/rm didn't work correctly"))

(assert (deep=
(assert (deep=
(sh/split ` "c d \" f" ' y z' a b a\ b --cflags `)
@["c d \" f" " y z" "a" "b" "a b" "--cflags"]))

(def new-dir ["assets" "18"])
(sh/create-dirs (path/join base-path ;new-dir))
(defer (do
(os/rm (path/join base-path ;new-dir "test.file"))
(os/rmdir (path/join base-path ;new-dir)))
(sh/copy (path/join base-path ;assets-dir "test.file")
(path/join base-path ;new-dir))
(assert (= :file (os/stat (path/join base-path ;new-dir "test.file") :mode))))

(end-suite)
Loading