resizer-store
Advanced tools
Comparing version 1.0.48 to 1.0.50
@@ -10,3 +10,3 @@ const chai = require('chai'); | ||
describe('CLI user interactions', () => { | ||
it('Select Icon 512 x 512', (done) => { | ||
it('Select Icon 512 x 512', done => { | ||
bddStdin(bddStdin.keys.down, '\n'); | ||
@@ -20,3 +20,3 @@ resizer.askAndReturnWhichSize().then(data => { | ||
it('Select Iphone 6.5"', (done) => { | ||
it('Select Iphone 6.5"', done => { | ||
bddStdin(bddStdin.keys.down, bddStdin.keys.down, '\n'); | ||
@@ -30,3 +30,3 @@ resizer.askAndReturnWhichSize().then(data => { | ||
it('Select Iphone 5.5"', (done) => { | ||
it('Select Iphone 5.5"', done => { | ||
bddStdin(bddStdin.keys.down, bddStdin.keys.down, bddStdin.keys.down, '\n'); | ||
@@ -40,3 +40,3 @@ resizer.askAndReturnWhichSize().then(data => { | ||
it('Select iPad', (done) => { | ||
it('Select iPad', done => { | ||
bddStdin( | ||
@@ -56,3 +56,3 @@ bddStdin.keys.down, | ||
it('Select Android Smartphone', (done) => { | ||
it('Select Android Smartphone', done => { | ||
bddStdin( | ||
@@ -73,3 +73,3 @@ bddStdin.keys.down, | ||
it('Select Android Smartphone', (done) => { | ||
it('Select Android Smartphone', done => { | ||
bddStdin( | ||
@@ -84,3 +84,3 @@ bddStdin.keys.down, | ||
); | ||
resizer.askAndReturnWhichSize().then((data) => { | ||
resizer.askAndReturnWhichSize().then(data => { | ||
assert.equal(data.width, 2048); | ||
@@ -93,3 +93,3 @@ assert.equal(data.height, 2732); | ||
describe('Create Directory', () => { | ||
it('Should create "resized directory"', (done) => { | ||
it('Should create "resized directory"', done => { | ||
resizer.createCopyDir({}).then(() => { | ||
@@ -102,3 +102,3 @@ if (fs.existsSync('./resized')) done(); | ||
describe('Resize Image Preview', () => { | ||
it('Should resize Icon to 512x512', (done) => { | ||
it('Should resize Icon to 512x512', done => { | ||
const content = { | ||
@@ -120,3 +120,3 @@ width: 512, | ||
it('Should resize image to 600x900', (done) => { | ||
it('Should resize image to 600x900', done => { | ||
const content = { | ||
@@ -123,0 +123,0 @@ width: 600, |
@@ -7,3 +7,3 @@ #!/usr/bin/env node | ||
resizeAndRemoveAlphaChannel, | ||
askCustomWidthAndHeight | ||
askCustomWidthAndHeight, | ||
} = require('../lib'); | ||
@@ -15,2 +15,6 @@ | ||
.then(createCopyDir) | ||
.then(resizeAndRemoveAlphaChannel); | ||
.then(resizeAndRemoveAlphaChannel) | ||
.catch(error => { | ||
console.error(error); | ||
process.exit(); | ||
}); |
module.exports = { | ||
cliOptions: [ | ||
{ title: 'Custom Size', value: { width: 0, height: 0 } }, | ||
{ title: 'Icon 512 x 512', value: { width: 512, height: 512 } }, | ||
{ title: 'iPhone 6.5" 1242 x 2688', value: { width: 1242, height: 2688 } }, | ||
{ title: 'iPhone 5.5" 1242 x 2208', value: { width: 1242, height: 2208 } }, | ||
{ title: 'iPad 2048 x 2732', value: { width: 2048, height: 2732 } }, | ||
{ title: 'Android Smartphone 1487 x 2644', value: { width: 1487, height: 2644 } }, | ||
{ title: 'Android Tablet 2048 x 2732', value: { width: 2048, height: 2732 } }, | ||
{title: 'Custom Size', value: {width: 0, height: 0}}, | ||
{title: 'Icon 512 x 512', value: {width: 512, height: 512}}, | ||
{title: 'iPhone 6.5" 1242 x 2688', value: {width: 1242, height: 2688}}, | ||
{title: 'iPhone 5.5" 1242 x 2208', value: {width: 1242, height: 2208}}, | ||
{title: 'iPad 2048 x 2732', value: {width: 2048, height: 2732}}, | ||
{ | ||
title: 'Android Smartphone 1487 x 2644', | ||
value: {width: 1487, height: 2644}, | ||
}, | ||
{title: 'Android Tablet 2048 x 2732', value: {width: 2048, height: 2732}}, | ||
], | ||
supportedImagesExtensions: [ | ||
"jpg", | ||
"png" | ||
] | ||
supportedImagesExtensions: ['jpg', 'png'], | ||
}; |
@@ -7,3 +7,3 @@ const prompts = require('prompts'); | ||
const { cliOptions, supportedImagesExtensions } = require('./constant'); | ||
const {cliOptions, supportedImagesExtensions} = require('./constant'); | ||
@@ -14,3 +14,3 @@ const resizedPathDir = 'resized'; | ||
createCopyDir(content) { | ||
return new Promise((resolve) => { | ||
return new Promise(resolve => { | ||
if (!fs.existsSync(resizedPathDir)) { | ||
@@ -24,3 +24,3 @@ fs.mkdirSync(resizedPathDir); | ||
askAndReturnWhichSize() { | ||
return new Promise(async (resolve) => { | ||
return new Promise(async (resolve, reject) => { | ||
try { | ||
@@ -36,5 +36,10 @@ const response = await prompts([ | ||
resolve(response.sizeChoice); | ||
} catch (err) { | ||
process.exit(); | ||
sizes = { | ||
width: Number(response.sizeChoice.width), | ||
height: Number(response.sizeChoice.height), | ||
}; | ||
resolve(sizes); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
@@ -45,4 +50,4 @@ }); | ||
askCustomWidthAndHeight(content) { | ||
return new Promise(async (resolve) => { | ||
if (content.width > 0 && content.height > 0) return resolve(); | ||
return new Promise(async resolve => { | ||
if (content.width > 0 && content.height > 0) return resolve(content); | ||
@@ -75,3 +80,3 @@ const responseCustomWidth = await prompts([ | ||
askAndReturnImages(content) { | ||
return new Promise(async (resolve) => { | ||
return new Promise(async (resolve, reject) => { | ||
const filesToChoice = fs | ||
@@ -86,3 +91,3 @@ .readdirSync('./') | ||
.map(file => { | ||
return { title: file, value: file }; | ||
return {title: file, value: file}; | ||
}); | ||
@@ -101,6 +106,5 @@ | ||
content.files = response.value; | ||
resolve(content); | ||
} catch (err) { | ||
process.exit(); | ||
} catch (error) { | ||
reject(error); | ||
} | ||
@@ -111,6 +115,6 @@ }); | ||
async resizeAndRemoveAlphaChannel(content) { | ||
if (!content.files) process.exit(); | ||
return new Promise((resolve, reject) => { | ||
if (!content.files) reject('No selected images'); | ||
return new Promise((resolve, reject) => { | ||
const { files, width, height } = content; | ||
const {files, width, height} = content; | ||
for (const file of files) { | ||
@@ -120,3 +124,3 @@ sharp(file) | ||
fit: 'fill', | ||
background: { r: 255, g: 255, b: 255, alpha: 1 }, | ||
background: {r: 255, g: 255, b: 255, alpha: 1}, | ||
}) | ||
@@ -128,3 +132,3 @@ .removeAlpha() | ||
) | ||
.catch(err => console.log(err)); | ||
.catch(reject); | ||
} | ||
@@ -131,0 +135,0 @@ |
{ | ||
"name": "resizer-store", | ||
"version": "1.0.48", | ||
"version": "1.0.50", | ||
"main": "./lib/index.js", | ||
@@ -13,3 +13,4 @@ "license": "MIT", | ||
"test": "mocha --timeout 5000 __test__/*.test.js", | ||
"format": "prettier --write \"**/*.js\"" | ||
"format": "prettier --write \"**/*.js\"", | ||
"precommit": "lint-staged && npm test" | ||
}, | ||
@@ -24,2 +25,8 @@ "repository": { | ||
"homepage": "https://github.com/otavioprimo/resizer#readme", | ||
"lint-staged": { | ||
"*.js": [ | ||
"npm run format", | ||
"git add" | ||
] | ||
}, | ||
"dependencies": { | ||
@@ -33,5 +40,7 @@ "colors": "^1.3.3", | ||
"chai": "^4.2.0", | ||
"husky": "^3.0.5", | ||
"lint-staged": "^9.2.5", | ||
"mocha": "^6.2.0", | ||
"prettier": "^1.18.2" | ||
} | ||
} | ||
} |
@@ -0,1 +1,3 @@ | ||
[![DeepScan grade](https://deepscan.io/api/teams/5435/projects/7225/branches/69159/badge/grade.svg)](https://deepscan.io/dashboard#view=project&tid=5435&pid=7225&bid=69159) | ||
# Image Resizer for App Store | ||
@@ -37,3 +39,1 @@ | ||
- Bug, when close the terminal in the first question, the second question shows up | ||
[![DeepScan grade](https://deepscan.io/api/teams/5435/projects/7225/branches/69159/badge/grade.svg)](https://deepscan.io/dashboard#view=project&tid=5435&pid=7225&bid=69159) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
375303
263
6