Last active
December 18, 2015 13:19
-
-
Save saihoooooooo/82adf1fc04d37bce50e8 to your computer and use it in GitHub Desktop.
generator test
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
Promise = require 'bluebird' | |
im = Promise.promisifyAll require 'imagemagick' | |
input = './img/bb.png' | |
resize = './img/resize.png' | |
crop = './img/crop.png' | |
exec = -> | |
ext = yield im.identifyAsync ['-format', '%m', input] | |
console.log ext.toLowerCase() | |
yield im.convertAsync [input, '-resize', '200x200!', resize] | |
yield im.convertAsync [resize, '-crop', '100x100', crop] | |
Promise.coroutine(exec)().catch (err) -> | |
console.log err |
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
const Promise = require('bluebird'); | |
const im = Promise.promisifyAll(require('imagemagick')); | |
const input = './img/bb.png'; | |
const resize = './img/resize.png'; | |
const crop = './img/crop.png'; | |
const exec = function*() { | |
const ext = yield im.identifyAsync(['-format', '%m', input]); | |
console.log(ext.toLowerCase()); | |
yield im.convertAsync([input, '-resize', '200x200!', resize]); | |
yield im.convertAsync([resize, '-crop', '100x100', crop]); | |
} | |
Promise.coroutine(exec)().catch((err) => { | |
console.log(err); | |
}); |
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
requirement | |
node v4.0.0 以上 or --harmony flag or --harmony-generators | |
npm install glob |
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
Promise = require 'bluebird' | |
im = Promise.promisifyAll require 'imagemagick' | |
client = require 'cheerio-httpcli' | |
globAsync = Promise.promisify require 'glob' | |
path = require 'path' | |
input = './img/bb.png' | |
resize = './img/resize.png' | |
crop = './img/crop.png' | |
teamName = 'xxx' | |
email = '[email protected]' | |
password = 'xxx' | |
exec = -> | |
ext = yield im.identifyAsync ['-format', '%m', input] | |
console.log ext.toLowerCase() | |
yield im.convertAsync [input, '-resize', '200x200!', resize] | |
yield im.convertAsync [resize, '-crop', '100x100', crop] | |
emojiPageUrl = "https://#{teamName}.slack.com/admin/emoji" | |
page = yield client.fetch emojiPageUrl | |
loginInput = | |
email: email | |
password: password | |
page = yield page.$('#signin_form').submit(loginInput) | |
if page.$.documentInfo().url != emojiPageUrl | |
throw new Error 'hogegeeeee' | |
files = yield globAsync('./img/crop*') | |
for file in files | |
emojiInput = | |
name: path.basename(file, 'png') | |
img: file | |
page = yield page.$('#addemoji').submit(loginInput) | |
console.log page.$('.alert_error').text() | |
Promise.coroutine(exec)().catch (err) -> | |
console.log err |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment