Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

resizer-store

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

resizer-store - npm Package Compare versions

Comparing version 1.0.44 to 1.0.46

.travis.yml

45

__test__/index.test.js
const chai = require('chai');
const bddStdin = require('bdd-stdin');
const fs = require('fs');
const resizer = require('../lib');

@@ -65,2 +67,3 @@

});
it('Select Android Smartphone', done => {

@@ -83,5 +86,45 @@ bddStdin(

describe('Create Directory', () => {
it('Should create "resized directory"', done => {
resizer.createCopyDir({}).then(() => {
if (fs.existsSync('./resized')) done();
});
});
});
describe('Resize Image Preview', () => {
it('Should resize Icon to 512x512', done => {
const content = {
width: 512,
height: 512,
files: ['test-1.jpg'],
};
resizer.resizeAndRemoveAlphaChannel(content).then(() => {
setTimeout(() => {
if (fs.existsSync('./resized/test-1.jpg')) {
fs.unlinkSync('./resized/test-1.jpg');
done();
}
}, 300);
});
});
it('Should resize image to 600x900', done => {
const content = {
width: 600,
height: 900,
files: ['test-2.jpg'],
};
resizer.resizeAndRemoveAlphaChannel(content).then(() => {
setTimeout(() => {
if (fs.existsSync('./resized/test-2.jpg')) {
fs.unlinkSync('./resized/test-2.jpg');
done();
}
}, 300);
});
});
});
});

51

lib/index.js

@@ -7,3 +7,3 @@ const prompts = require('prompts');

const { cliOptions } = require('./constant');
const {cliOptions} = require('./constant');

@@ -43,4 +43,3 @@ const resizedPathDir = 'resized';

return new Promise(async resolve => {
if (content.width > 0 && content.height > 0)
return resolve();
if (content.width > 0 && content.height > 0) return resolve();

@@ -52,3 +51,3 @@ const responseCustomWidth = await prompts([

message: colors.yellow('Digite a largura desejada'),
}
},
]);

@@ -61,3 +60,3 @@

message: colors.yellow('Digite a altura desejada'),
}
},
]);

@@ -67,4 +66,4 @@

width: Number(responseCustomWidth.width),
height: Number(responseCustomHeight.height)
}
height: Number(responseCustomHeight.height),
};

@@ -77,3 +76,4 @@ resolve(sizes);

return new Promise(async resolve => {
const filesToChoice = fs.readdirSync('./')
const filesToChoice = fs
.readdirSync('./')
.filter(file => {

@@ -84,3 +84,3 @@ const stat = fs.lstatSync(file);

.map(file => {
return { title: file, value: file };
return {title: file, value: file};
});

@@ -108,18 +108,23 @@

async resizeAndRemoveAlphaChannel(content) {
if (!content.files)
process.exit();
if (!content.files) process.exit();
const { files, width, height } = content;
for (const file of files) {
sharp(file)
.resize(width, height, {
fit: 'fill',
background: { r: 255, g: 255, b: 255, alpha: 1 }
})
.removeAlpha()
.toBuffer()
.then(data => fs.writeFileSync(path.resolve(resizedPathDir, file), data))
.catch(err => console.log(err))
}
return new Promise((resolve, reject) => {
const {files, width, height} = content;
for (const file of files) {
sharp(file)
.resize(width, height, {
fit: 'fill',
background: {r: 255, g: 255, b: 255, alpha: 1},
})
.removeAlpha()
.toBuffer()
.then(data =>
fs.writeFileSync(path.resolve(resizedPathDir, file), data),
)
.catch(err => console.log(err));
}
resolve();
});
},
};
{
"name": "resizer-store",
"version": "1.0.44",
"version": "1.0.46",
"main": "./lib/index.js",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -35,3 +35,5 @@ # Image Resizer for App Store

- Eslint
- Test for custom sizes
- Test for custom sizes and resize images
- 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)

Sorry, the diff of this file is not supported yet

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