Skip to content

Commit

Permalink
Merge 88a72f5 into 3b5e072
Browse files Browse the repository at this point in the history
  • Loading branch information
ajuste committed May 21, 2017
2 parents 3b5e072 + 88a72f5 commit f8acb74
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 27 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ compile:

# Compile tests
compile-tests: compile
rm -rf ./test-compiled
@$(COFFEE) --output ./test-compiled --no-header --compile -b ./test

# Run lint for coffeescript
Expand Down
6 changes: 5 additions & 1 deletion lib/filesystem-google-storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ GoogleStorageClient = (function() {
*/

GoogleStorageClient.prototype.readFile = function(path) {
return this.file(path).createReadStream();
return new Promise((function(_this) {
return function(res) {
return res(_this.file(path).createReadStream());
};
})(this));
};


Expand Down
18 changes: 1 addition & 17 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1 @@
var FsClient, GoogleStorageClient, Manager, ReadResult, S3Bucket, ref;

ref = require('./filesystem-manager'), Manager = ref.Manager, ReadResult = ref.ReadResult;

FsClient = require('./filesystem-fs').FsClient;

S3Bucket = require('./filesystem-s3').S3Bucket;

GoogleStorageClient = require('./filesystem-google-storage').GoogleStorageClient;

module.exports = {
Manager: Manager,
ReadResult: ReadResult,
FsClient: FsClient,
S3Bucket: S3Bucket,
GoogleStorageClient: GoogleStorageClient
};
module.exports = Object.assign({}, require('./filesystem-manager'), require('./filesystem-fs'), require('./filesystem-s3'), require('./filesystem-google-storage'));
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jaune-fs",
"version": "0.0.6",
"version": "0.0.7",
"description": "file system for jaune framework",
"main": "index.js",
"scripts": {
Expand Down
4 changes: 3 additions & 1 deletion src/filesystem-google-storage.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ class GoogleStorageClient
* @param {String} path The key of the object
* @returns {Stream}
###
readFile : (path) -> @file(path).createReadStream()
readFile : (path) ->
new Promise (res) =>
res @file(path).createReadStream()

###*
* @function Checks if file exists.
Expand Down
18 changes: 11 additions & 7 deletions test/filesystem-google-storage/readFile.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ describe 'filesystem-google-storage-fs', ->

@fs
.readFile FileNameOrigin
.on 'data', (data) ->
equal data.toString('utf-8'), FileData
.on 'end', cb
.on 'error', (err) -> cb equal null, err
.then (stream) ->
stream
.on 'data', (data) ->
equal data.toString('utf-8'), FileData
.on 'end', cb
.on 'error', (err) -> cb equal null, err

describe 'failing', ->

Expand Down Expand Up @@ -93,6 +95,8 @@ describe 'filesystem-google-storage-fs', ->

it 'should fail to read non existing file', (cb) ->

new PassThrough().pipe(@fs
.readFile FileNameOriginNonExisting
.on 'error', ({code}) -> cb equal code, 500)
@fs
.readFile FileNameOriginNonExisting
.then (stream) ->
new PassThrough().pipe(
stream.on 'error', ({code}) -> cb equal code, 500)

0 comments on commit f8acb74

Please sign in to comment.