Skip to content

Commit

Permalink
fix: Build operation removes folder prefix from image names 🐛
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Image names might be different compared to previous
versions, which were not correctly removing the folder prefix.
  • Loading branch information
avaly committed Sep 6, 2019
1 parent b01cb5a commit fbebda8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
9 changes: 4 additions & 5 deletions __tests__/buildFolder.test.js
@@ -1,18 +1,17 @@
import path from 'path';
import VisWiz from '../es';
import nock from '../utils/nock';

const FIXTURES = path.resolve(__dirname, '..', '__fixtures__');
const FIXTURES = './__fixtures__/';

let instance;

function validateRequestBody(body, imageName, fileName) {
function validateRequestBody(body, fileName, imageName) {
const raw = Buffer.from(body, 'hex').toString();
return (
raw.includes('Content-Disposition: form-data; name="name"') &&
raw.includes(imageName) &&
raw.includes(fileName) &&
raw.includes(
`Content-Disposition: form-data; name="image"; filename="${fileName}"`
`Content-Disposition: form-data; name="image"; filename="${imageName}"`
)
);
}
Expand Down
5 changes: 3 additions & 2 deletions src/sdk.js
Expand Up @@ -408,7 +408,8 @@ class VisWiz {
* }, '/path/to/folder/with/images');
*/
async buildFolder(build, folderPath, progressCallback) {
const imageFiles = glob.sync(path.join(folderPath, '**/*.png'));
const fullPath = path.resolve(folderPath);
const imageFiles = glob.sync(path.join(fullPath, '**/*.png'));
const total = imageFiles.length;
if (!total) {
return Promise.reject(
Expand All @@ -421,7 +422,7 @@ class VisWiz {

await imageFiles.reduce((chain, imageFile, index) => {
const name = imageFile
.replace(folderPath, '')
.replace(fullPath, '')
.replace(/^[/\\]/, '')
.replace(/\.png$/i, '')
.replace(/[/\\]/g, '__');
Expand Down

0 comments on commit fbebda8

Please sign in to comment.