This repository has been archived by the owner on Jul 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/stojanovic/scottyjs
# Conflicts: # package.json
- Loading branch information
Showing
17 changed files
with
1,671 additions
and
480 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,5 @@ | ||
language: node_js | ||
node_js: | ||
- 4.3.2 | ||
- 6.11.2 | ||
- 8.4.0 |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict' | ||
|
||
const AWS = require('aws-sdk') | ||
const s3 = new AWS.S3() | ||
const emptyBucket = require('./empty-bucket') | ||
|
||
function deleteBucket(name, s3lib) { | ||
s3lib = s3lib || s3 | ||
|
||
if (!name) | ||
return Promise.reject('Bucket name is required') | ||
|
||
const options = { | ||
Bucket: name | ||
} | ||
|
||
return emptyBucket(name) | ||
.then(() => s3lib.deleteBucket(options).promise()) | ||
.then(() => name) | ||
} | ||
|
||
module.exports = deleteBucket |
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,30 @@ | ||
'use strict' | ||
|
||
const AWS = require('aws-sdk') | ||
const s3 = new AWS.S3() | ||
|
||
function deleteObjects(bucketName, keys, s3lib) { | ||
s3lib = s3lib || s3 | ||
|
||
if (!bucketName || !keys || !Array.isArray(keys)) | ||
return Promise.reject('Bucket name or an array of keys are required') | ||
|
||
const options = { | ||
Bucket: bucketName, | ||
Delete: { | ||
Objects: [], | ||
Quiet: false | ||
} | ||
} | ||
|
||
keys.forEach(key => { | ||
options.Delete.Objects.push({Key: key}) | ||
}) | ||
|
||
if (keys.length < 1) | ||
return Promise.resolve() | ||
|
||
return s3lib.deleteObjects(options).promise() | ||
} | ||
|
||
module.exports = deleteObjects |
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,27 @@ | ||
'use strict' | ||
|
||
const AWS = require('aws-sdk') | ||
const s3 = new AWS.S3() | ||
const deleteObjects = require('./delete-objects') | ||
|
||
function emptyBucket(name, s3lib) { | ||
s3lib = s3lib || s3 | ||
|
||
if (!name) | ||
return Promise.reject('Bucket name is required') | ||
|
||
const options = { | ||
Bucket: name | ||
} | ||
|
||
return s3lib.listObjectsV2(options) | ||
.promise() | ||
.then(result => { | ||
let keys = result.Contents.map(item => item.Key) | ||
return deleteObjects(name, keys, s3lib) | ||
}) | ||
.catch(err => { | ||
throw err }) | ||
} | ||
|
||
module.exports = emptyBucket |
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
Oops, something went wrong.