mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
Add fs.split
This commit is contained in:
@@ -41,6 +41,11 @@ describe "fs", ->
|
||||
expect(fs.join('/a/b/', 'c', 'd')).toBe '/a/b/c/d'
|
||||
expect(fs.join('a', 'b/c/', 'd/')).toBe 'a/b/c/d/'
|
||||
|
||||
describe ".split(path)", ->
|
||||
it "returns path components", ->
|
||||
expect(fs.split("/a/b/c.txt")).toEqual ["", "a", "b", "c.txt"]
|
||||
expect(fs.split("a/b/c.txt")).toEqual ["a", "b", "c.txt"]
|
||||
|
||||
describe ".extension(path)", ->
|
||||
it "returns the extension of a file", ->
|
||||
expect(fs.extension("a/b/corey.txt")).toBe '.txt'
|
||||
|
||||
@@ -77,6 +77,15 @@ module.exports =
|
||||
read: (path) ->
|
||||
$native.read(path)
|
||||
|
||||
# Returns an array of path components. If the path is absolute, the first
|
||||
# component will be an indicator of the root of the file system; for file
|
||||
# systems with drives (such as Windows), this is the drive identifier with a
|
||||
# colon, like "c:"; on Unix, this is an empty string "". The intent is that
|
||||
# calling "join.apply" with the result of "split" as arguments will
|
||||
# reconstruct the path.
|
||||
split: (path) ->
|
||||
path.split("/")
|
||||
|
||||
# Open, write, flush, and close a file, writing the given content.
|
||||
write: (path, content) ->
|
||||
$native.write(path, content)
|
||||
|
||||
Reference in New Issue
Block a user