Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
84 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
--require ts-node/register | ||
--require source-map-support/register | ||
--recursive | ||
--timeout=1000 | ||
src/test/**/*.{ts,js} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { statSync } from "fs"; | ||
|
||
export function fileExistsSync(path: string): boolean { | ||
try { | ||
return statSync(path).isFile(); | ||
} catch (e) { | ||
return false; | ||
} | ||
} | ||
|
||
export function dirExistsSync(path: string): boolean { | ||
try { | ||
return statSync(path).isDirectory(); | ||
} catch (e) { | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { expect } from "chai"; | ||
|
||
import * as fsutils from "../fsutils"; | ||
|
||
describe("fsutils", () => { | ||
describe("fileExistsSync", () => { | ||
it("should return true if the file exists", () => { | ||
expect(fsutils.fileExistsSync(__filename)).to.be.true; | ||
}); | ||
|
||
it("should return false if the file does not exist", () => { | ||
expect(fsutils.fileExistsSync(`${__filename}/nope.never`)).to.be.false; | ||
}); | ||
|
||
it("should return false if the path is a directory", () => { | ||
expect(fsutils.fileExistsSync(__dirname)).to.be.false; | ||
}); | ||
}); | ||
|
||
describe("dirExistsSync", () => { | ||
it("should return true if the directory exists", () => { | ||
expect(fsutils.dirExistsSync(__dirname)).to.be.true; | ||
}); | ||
|
||
it("should return false if the directory does not exist", () => { | ||
expect(fsutils.dirExistsSync(`${__dirname}/nope/never`)).to.be.false; | ||
}); | ||
|
||
it("should return false if the path is a file", () => { | ||
expect(fsutils.dirExistsSync(__filename)).to.be.false; | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,31 @@ | ||
import { expect } from "chai"; | ||
|
||
import * as path from "path"; | ||
import { resolve } from "path"; | ||
|
||
import { listFiles } from "../listFiles"; | ||
|
||
describe("listFiles", () => { | ||
// for details, see the file structure and firebase.json in test/fixtures/ignores | ||
it("should ignore firebase-debug.log, specified ignores, and nothing else", () => { | ||
const fileNames = listFiles(path.resolve(__dirname, "./fixtures/ignores"), [ | ||
const fileNames = listFiles(resolve(__dirname, "./fixtures/ignores"), [ | ||
"**/.*", | ||
"firebase.json", | ||
"ignored.txt", | ||
"ignored/**/*.txt", | ||
]); | ||
expect(fileNames).to.deep.equal(["index.html", "ignored/index.html", "present/index.html"]); | ||
}); | ||
|
||
it("should allow us to not specify additional ignores", () => { | ||
const fileNames = listFiles(resolve(__dirname, "./fixtures/ignores")); | ||
expect(fileNames.sort()).to.have.members([ | ||
".hiddenfile", | ||
"firebase.json", | ||
"ignored.txt", | ||
"ignored/deeper/index.txt", | ||
"ignored/ignore.txt", | ||
"ignored/index.html", | ||
"index.html", | ||
"present/index.html", | ||
]); | ||
}); | ||
}); |