Files
cypress/packages/server/lib/files.coffee
T
Brian Mann 40813b1954 Issue 416 431 681 980 1248 (#1583)
* extract random string to util

* run specs in isolation, aggregate totalFailures, display output per spec, enable globbing for specs

* extract electron app ready into its own module

* WIP: e2e tests around spec isolation, snapshots, stdout, and complete test results

* removed unused and deprecated remove id's feature

* move fs_warn to fs util to promisify an fs singleton

* create a glob singleton util

* cleanup dead removeIds code

* extract files controller specs into its own file

* extract finding specs out of project instance into its own utility with no state

* use glob util singleton

* use fs util singleton

* lots of formatting and cleanup

* fixes failing headless specs

* fixes all failing unit tests

* fixes failing integration test

* WIP: temporarily throw old error msg

* WIP: skip failing --record integration tests for now

* fix failing e2e tests
2018-04-14 23:13:44 -04:00

35 lines
842 B
CoffeeScript

path = require("path")
Promise = require("bluebird")
fs = require("./util/fs")
module.exports = {
readFile: (projectRoot, file, options = {}) ->
filePath = path.join(projectRoot, file)
readFn = if path.extname(filePath) is ".json"
fs.readJsonAsync
else
fs.readFileAsync
readFn(filePath, options.encoding or "utf8")
.then (contents) ->
{
contents: contents
filePath: filePath
}
.catch (err) ->
err.filePath = filePath
throw err
writeFile: (projectRoot, file, contents, options = {}) ->
filePath = path.join(projectRoot, file)
fs.outputFileAsync(filePath, contents, options.encoding or "utf8")
.then ->
{
contents: contents
filePath: filePath
}
.catch (err) ->
err.filePath = filePath
throw err
}