Skip to content

Commit

Permalink
Add support for getDirectories on nightlies (#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeembrey authored Jul 21, 2016
1 parent 14b4edc commit 240d4b9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"semver": "^5.1.0",
"tslint": "^3.10.2",
"tslint-config-standard": "^1.0.0",
"typescript": "1.8.7",
"typescript": "^1.8.10",
"typings": "^1.0.4"
},
"dependencies": {
Expand Down
22 changes: 21 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { relative, basename, extname, resolve, dirname, sep, join } from 'path'
import { writeFileSync, readFileSync, statSync } from 'fs'
import { readdirSync, writeFileSync, readFileSync, statSync } from 'fs'
import { EOL, tmpdir } from 'os'
import sourceMapSupport = require('source-map-support')
import extend = require('xtend')
Expand Down Expand Up @@ -208,6 +208,8 @@ export function register (opts?: Options): () => Register {

return ts.ScriptSnapshot.fromString(options.getFile(fileName))
},
getDirectories: getDirectories,
directoryExists: directoryExists,
getNewLine: () => EOL,
getCurrentDirectory: () => cwd,
getCompilationSettings: () => config.options,
Expand Down Expand Up @@ -505,6 +507,24 @@ export function fileExists (fileName: string): boolean {
}
}

/**
* Get directories within a directory.
*/
export function getDirectories (path: string): string[] {
return readdirSync(path).filter(name => directoryExists(join(path, name)))
}

/**
* Check if a directory exists.
*/
export function directoryExists (path: string): boolean {
try {
return statSync(path).isDirectory()
} catch (err) {
return false
}
}

/**
* Get the file from the file system.
*/
Expand Down

0 comments on commit 240d4b9

Please sign in to comment.