-
Notifications
You must be signed in to change notification settings - Fork 11
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
1 parent
03fde30
commit a369873
Showing
1 changed file
with
35 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
nock = require 'nock' | ||
path = require 'path' | ||
fs = require 'fs' | ||
|
||
UPDATE_ENV_VAR = "IMJS_TESTS_UPDATE" | ||
BUNDLES_FOLDER = path.join __dirname, 'bundledResponses' | ||
|
||
shouldUpdate = -> | ||
process.env[UPDATE_ENV_VAR] is "TRUE" | ||
|
||
startUpdater = -> | ||
if not shouldUpdate() | ||
return | ||
|
||
nock.recorder.recorder | ||
output_objects: true | ||
|
||
stopUpdater = (bundleName) -> | ||
if not shouldUpdate() | ||
return | ||
|
||
fullPath = path.join BUNDLES_FOLDER, bundleName | ||
console.log fullPath | ||
|
||
if fs.existsSync fullPath | ||
newPath = path.join BUNDLES_FOLDER, '.bak.' + bundleName | ||
try | ||
console.log "Bundle already existing. Renaming original #{bundleName} to .bak.#{bundleName}" | ||
fs.renameSync fullPath, newPath | ||
catch e then console.log "Unable to rename #{bundleName} to .bak.#{bundleName}" | ||
|
||
|
||
module.exports = | ||
startUpdater: startUpdater | ||
stopUpdater: stopUpdater |