New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nightmare-swiftly

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nightmare-swiftly - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

9

History.md
n.n.n / 2014-04-08
n.n.n / 2014-04-11
==================
* fixing download and .wait(fn)
* updating readme with new macros
* fixing history
0.0.3 / 2014-04-08
==================
* adding several more macros

@@ -6,0 +13,0 @@ * fixing history

71

index.js

@@ -9,3 +9,3 @@

exports.login = function(email, password){
var login = exports.login = function(email, password){
return function(nightmare) {

@@ -22,2 +22,20 @@ nightmare

/**
* Execute an entire task on Swiftly.
*
* @param {String} instructions
* @param {Array} uploads
* @param {String} path
*/
var task = exports.task = function(instructions, uploads, path) {
return function(nightmare) {
nightmare
.use(create(instructions, uploads))
.use(onState('Delivered'))
.use(download(path))
.use(approve());
};
};
/**
* Create a new task on Swiftly.

@@ -30,3 +48,3 @@ *

exports.task = function(instructions, uploads, callback){
var create = exports.create = function (instructions, uploads){
return function(nightmare){

@@ -47,6 +65,3 @@ nightmare

.click('#pay-button')
.wait()
.evaluate(function () {
return window.location.href;
}, callback);
.wait();
};

@@ -58,23 +73,13 @@ };

*
* @param {String} url
* @param {String} state "Delivered", "Approved"
* @param {Function} callback
*/
exports.onState = function(url, state, callback) {
var spacing = 1000 * 60 * 10; // 10 minutes
var onState = exports.onState = function(state) {
var between = 1000 * 60 * 10; // 10 minutes
return function(nightmare){
var interval = setInterval(function () {
nightmare
.goto(url)
.evaluate(function () {
var pill = document.querySelector('.pill');
return (pill ? pill.textContent : '');
}, function (status) {
if (status === 'Delivered') {
cancelInterval(interval);
callback();
}
});
}, spacing);
nightmare
.wait(function () {
var pill = document.querySelector('.pill');
return (pill ? pill.textContent : '');
}, state, between);
};

@@ -86,10 +91,11 @@ };

*
* @param {String} path
* @param {String} url
* @param {String} path
*/
exports.download = function(url, path) {
var download = exports.download = function(path, url) {
return function(nightmare){
if (url) nightmare.goto(url);
nightmare
.run(function () {
.evaluate(function () {
var urls = document.querySelectorAll('.attachment__actions__download')

@@ -104,5 +110,7 @@ .map(function (link) {

}, function (urls) {
done();
urls.forEach(function (file) {
exec('wget -P ' + path + ' ' + file);
});
})
.wait(1000);
.wait(3000);
};

@@ -117,4 +125,5 @@ };

exports.approve = function(url) {
var approve = exports.approve = function(url) {
return function(nightmare){
if (url) nightmare.goto(url);
nightmare

@@ -126,2 +135,4 @@ .click('.task-actions .button--primary')

};
};
};
{
"name": "nightmare-swiftly",
"version": "0.0.3",
"version": "0.0.4",
"author": "Segment.io",

@@ -5,0 +5,0 @@ "keywords": [

@@ -10,6 +10,18 @@ nightmare-swiftly

### .task(description, uploads)
### .task(instructions, uploads, callback)
Create a new task, uploads is an array of string paths, must include at least one upload by Swiftly rules.
Create a new task, uploads is an array of string paths, must include at least one upload by Swiftly rules. The callback signature is `cb(taskUrl)`.
### .onState(taskUrl, state, callback)
Lets you wait until a task hits a state like "Completed" or "Approved".
### .download(taskUrl, path)
Download all the files produced with the task to the `path`.
### .approve(taskUrl)
Approve the completed task.
## License (MIT)

@@ -16,0 +28,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc