-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from cyclic-software/object-function-mode
fix: make it work like both function or object
- Loading branch information
Showing
6 changed files
with
96 additions
and
21 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
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
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,11 +1,22 @@ | ||
const fs = require('fs/promises') | ||
const CyclicS3FSPromises = require('./CyclicS3FSPromises') | ||
const client = function(bucketName, config={}){ | ||
if(!process.env.AWS_SECRET_ACCESS_KEY){ | ||
console.warn('[s3fs] WARNING: AWS credentials are not set. Using local file system') | ||
return fs | ||
var client = new CyclicS3FSPromises() | ||
class FSPromisesFallback extends Function{ | ||
constructor() { | ||
super('...args', 'return this._bound._call(...args)') | ||
this._bound = this.bind(this) | ||
Object.assign(this._bound,{...fs}) | ||
return this._bound | ||
} | ||
_call() { | ||
let client = new FSPromisesFallback() | ||
return client | ||
} | ||
return new CyclicS3FSPromises(bucketName, config) | ||
} | ||
|
||
if(!process.env.AWS_SECRET_ACCESS_KEY){ | ||
console.warn('[s3fs] WARNING: AWS credentials are not set. Using local file system') | ||
client = new FSPromisesFallback() | ||
} | ||
|
||
module.exports = client |
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