Skip to content

Commit 107c6b4

Browse files
committed
Upgrade dependencies
1 parent 19677ad commit 107c6b4

File tree

9 files changed

+148
-140
lines changed

9 files changed

+148
-140
lines changed

.babelrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"presets": [
3-
["es2015", { "loose": true }]
3+
["@babel/preset-env", { "loose": true }]
44
],
55
"plugins": [
6-
"add-module-exports"
6+
"@babel/plugin-transform-runtime"
77
]
88
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
node_modules/
33
test/build/
44
lib/
5+
package-lock.json

package.json

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
"svg"
1515
],
1616
"scripts": {
17-
"test": "./node_modules/.bin/ava test/*.js --verbose --serial",
18-
"build": "./node_modules/.bin/babel src/ --out-dir lib/",
19-
"watch": "./node_modules/.bin/babel --watch src/ --out-dir lib/",
17+
"test": "ava test/*.js --verbose --serial",
18+
"build": "babel src/ --out-dir lib/",
19+
"watch": "babel --watch src/ --out-dir lib/",
2020
"prepublish": "npm test",
2121
"pretest": "npm run build"
2222
},
@@ -26,22 +26,29 @@
2626
"bugs": "https://github.com/2createStudio/postcss-sprites/issues",
2727
"homepage": "https://github.com/2createStudio/postcss-sprites#readme",
2828
"devDependencies": {
29-
"ava": "^0.15.2",
30-
"babel-cli": "^6.4.0",
31-
"babel-plugin-add-module-exports": "^0.2.1",
32-
"babel-preset-es2015": "^6.3.13",
29+
"@ava/babel": "^2.0.0",
30+
"@babel/cli": "^7.16.0",
31+
"@babel/plugin-transform-runtime": "^7.16.0",
32+
"@babel/preset-env": "^7.16.0",
33+
"ava": "^3.15.0",
3334
"postcss": "^8.1.2"
3435
},
3536
"dependencies": {
3637
"bluebird": "^3.1.1",
37-
"debug": "^2.6.0",
38-
"fs-extra": "^0.26.4",
38+
"debug": "^4.3.2",
39+
"fs-extra": "^10.0.0",
3940
"lodash": "^4.0.0",
4041
"spritesmith": "^3.0.1",
4142
"svg-sprite": "^1.3.5"
4243
},
4344
"peerDependencies": {
4445
"postcss": "^8.1.2"
4546
},
46-
"typings": "./typings.d.ts"
47+
"typings": "./typings.d.ts",
48+
"engines": {
49+
"node": ">=12"
50+
},
51+
"ava": {
52+
"babel": true
53+
}
4754
}

test/07-run-spritesmith.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ test.beforeEach((t) => {
1212
});
1313

1414
test('should generate spritesheets', async (t) => {
15-
const cssContents = await readFileAsync('./fixtures/basic/style.css');
16-
const ast = postcss.parse(cssContents, { from: './fixtures/basic/style.css' });
15+
const cssContents = await readFileAsync('./test/fixtures/basic/style.css');
16+
const ast = postcss.parse(cssContents, { from: './test/fixtures/basic/style.css' });
1717
let images, spritesheets, opts;
1818

1919
[ opts, images ] = await extractImages(ast, t.context.opts);
@@ -24,8 +24,8 @@ test('should generate spritesheets', async (t) => {
2424
});
2525

2626
test('should generate SVG spritesheets', async (t) => {
27-
const cssContents = await readFileAsync('./fixtures/svg-basic/style.css');
28-
const ast = postcss.parse(cssContents, { from: './fixtures/svg-basic/style.css' });
27+
const cssContents = await readFileAsync('./test/fixtures/svg-basic/style.css');
28+
const ast = postcss.parse(cssContents, { from: './test/fixtures/svg-basic/style.css' });
2929
let images, spritesheets, opts;
3030

3131
prepareGroupBy(t.context.opts);
@@ -38,8 +38,8 @@ test('should generate SVG spritesheets', async (t) => {
3838
});
3939

4040
test('should generate spritesheets by groups', async (t) => {
41-
const cssContents = await readFileAsync('./fixtures/retina/style.css');
42-
const ast = postcss.parse(cssContents, { from: './fixtures/retina/style.css' });
41+
const cssContents = await readFileAsync('./test/fixtures/retina/style.css');
42+
const ast = postcss.parse(cssContents, { from: './test/fixtures/retina/style.css' });
4343
let images, spritesheets, opts;
4444

4545
t.context.opts.retina = true;

test/08-save-spritesheets.js

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -20,43 +20,43 @@ test.beforeEach((t) => {
2020
});
2121

2222
test('should save spritesheets', async (t) => {
23-
const cssContents = await readFileAsync('./fixtures/basic/style.css');
24-
const ast = postcss.parse(cssContents, { from: './fixtures/basic/style.css' });
23+
const cssContents = await readFileAsync('./test/fixtures/basic/style.css');
24+
const ast = postcss.parse(cssContents, { from: './test/fixtures/basic/style.css' });
2525
let images, spritesheets, opts;
2626

27-
t.context.opts.spritePath = './build/basic';
27+
t.context.opts.spritePath = './test/build/basic';
2828

2929
[ opts, images ] = await extractImages(ast, t.context.opts);
3030
[ opts, images, spritesheets ] = await runSpritesmith(t.context.opts, images);
3131
[ opts, images, spritesheets ] = await saveSpritesheets(t.context.opts, images, spritesheets);
3232

33-
t.deepEqual(spritesheets[0].path, 'build/basic/sprite.png');
34-
t.truthy(fs.statAsync('./build/basic/sprite.png'));
33+
t.deepEqual(spritesheets[0].path, 'test/build/basic/sprite.png');
34+
t.truthy(fs.statAsync('./test/build/basic/sprite.png'));
3535
});
3636

3737
test('should save SVG spritesheets', async (t) => {
38-
const cssContents = await readFileAsync('./fixtures/svg-basic/style.css');
39-
const ast = postcss.parse(cssContents, { from: './fixtures/svg-basic/style.css' });
38+
const cssContents = await readFileAsync('./test/fixtures/svg-basic/style.css');
39+
const ast = postcss.parse(cssContents, { from: './test/fixtures/svg-basic/style.css' });
4040
let images, spritesheets, opts;
4141

42-
t.context.opts.spritePath = './build/svg-basic';
42+
t.context.opts.spritePath = './test/build/svg-basic';
4343

4444
prepareGroupBy(t.context.opts);
4545
[ opts, images ] = await extractImages(ast, t.context.opts);
4646
[ opts, images ] = await applyGroupBy(t.context.opts, images);
4747
[ opts, images, spritesheets ] = await runSpritesmith(t.context.opts, images);
4848
[ opts, images, spritesheets ] = await saveSpritesheets(t.context.opts, images, spritesheets);
4949

50-
t.deepEqual(spritesheets[0].path, 'build/svg-basic/sprite.svg');
51-
t.truthy(fs.statAsync('./build/svg-basic/sprite.svg'));
50+
t.deepEqual(spritesheets[0].path, 'test/build/svg-basic/sprite.svg');
51+
t.truthy(fs.statAsync('./test/build/svg-basic/sprite.svg'));
5252
});
5353

5454
test('should save spritesheets by groups', async (t) => {
55-
const cssContents = await readFileAsync('./fixtures/retina/style.css');
56-
const ast = postcss.parse(cssContents, { from: './fixtures/retina/style.css' });
55+
const cssContents = await readFileAsync('./test/fixtures/retina/style.css');
56+
const ast = postcss.parse(cssContents, { from: './test/fixtures/retina/style.css' });
5757
let images, spritesheets, opts;
5858

59-
t.context.opts.spritePath = './build/retina';
59+
t.context.opts.spritePath = './test/build/retina';
6060
t.context.opts.retina = true;
6161

6262
prepareGroupBy(t.context.opts);
@@ -66,18 +66,18 @@ test('should save spritesheets by groups', async (t) => {
6666
[ opts, images, spritesheets ] = await runSpritesmith(t.context.opts, images);
6767
[ opts, images, spritesheets ] = await saveSpritesheets(t.context.opts, images, spritesheets);
6868

69-
t.deepEqual(spritesheets[0].path, 'build/retina/sprite.png');
70-
t.deepEqual(spritesheets[1].path, 'build/retina/sprite.@2x.png');
71-
t.truthy(fs.statAsync('./build/retina/sprite.png'));
72-
t.truthy(fs.statAsync('./build/retina/sprite.@2x.png'));
69+
t.deepEqual(spritesheets[0].path, 'test/build/retina/sprite.png');
70+
t.deepEqual(spritesheets[1].path, 'test/build/retina/sprite.@2x.png');
71+
t.truthy(fs.statAsync('./test/build/retina/sprite.png'));
72+
t.truthy(fs.statAsync('./test/build/retina/sprite.@2x.png'));
7373
});
7474

7575
test('should use path provided by book', async (t) => {
76-
const cssContents = await readFileAsync('./fixtures/basic/style.css');
77-
const ast = postcss.parse(cssContents, { from: './fixtures/basic/style.css' });
76+
const cssContents = await readFileAsync('./test/fixtures/basic/style.css');
77+
const ast = postcss.parse(cssContents, { from: './test/fixtures/basic/style.css' });
7878
let images, spritesheets, opts;
7979

80-
t.context.opts.spritePath = './build/on-save-hook/';
80+
t.context.opts.spritePath = './test/build/on-save-hook/';
8181
t.context.opts.hooks.onSaveSpritesheet = (pluginOpts, spritesheetGroups) => {
8282
return path.join(pluginOpts.spritePath, 'custom-name.png');
8383
}
@@ -86,32 +86,32 @@ test('should use path provided by book', async (t) => {
8686
[ opts, images, spritesheets ] = await runSpritesmith(t.context.opts, images);
8787
[ opts, images, spritesheets ] = await saveSpritesheets(t.context.opts, images, spritesheets);
8888

89-
t.deepEqual(spritesheets[0].path, 'build/on-save-hook/custom-name.png');
90-
t.truthy(fs.statAsync('./build/on-save-hook/custom-name.png'));
89+
t.deepEqual(spritesheets[0].path, 'test/build/on-save-hook/custom-name.png');
90+
t.truthy(fs.statAsync('./test/build/on-save-hook/custom-name.png'));
9191
});
9292

9393
test('should throw error if path is empty', async (t) => {
94-
const cssContents = await readFileAsync('./fixtures/basic/style.css');
95-
const ast = postcss.parse(cssContents, { from: './fixtures/basic/style.css' });
94+
const cssContents = await readFileAsync('./test/fixtures/basic/style.css');
95+
const ast = postcss.parse(cssContents, { from: './test/fixtures/basic/style.css' });
9696
let images, spritesheets, opts;
9797

98-
t.context.opts.spritePath = './build/on-save-hook/';
98+
t.context.opts.spritePath = './test/build/on-save-hook/';
9999
t.context.opts.hooks.onSaveSpritesheet = (pluginOpts, spritesheetGroups) => {
100100
return '';
101101
}
102102

103103
[ opts, images ] = await extractImages(ast, t.context.opts);
104104
[ opts, images, spritesheets ] = await runSpritesmith(t.context.opts, images);
105105

106-
t.throws(saveSpritesheets(t.context.opts, images, spritesheets));
106+
return t.throwsAsync(() => saveSpritesheets(t.context.opts, images, spritesheets));
107107
});
108108

109109
test('should use Promise result provided by book', async (t) => {
110-
const cssContents = await readFileAsync('./fixtures/basic/style.css');
111-
const ast = postcss.parse(cssContents, { from: './fixtures/basic/style.css' });
110+
const cssContents = await readFileAsync('./test/fixtures/basic/style.css');
111+
const ast = postcss.parse(cssContents, { from: './test/fixtures/basic/style.css' });
112112
let images, spritesheets, opts;
113113

114-
t.context.opts.spritePath = './build/on-save-hook/';
114+
t.context.opts.spritePath = './test/build/on-save-hook/';
115115
t.context.opts.hooks.onSaveSpritesheet = (pluginOpts, spritesheetGroups) => {
116116
return new Promise(( resolve ) => setTimeout(() => resolve(Promise.resolve(path.join(pluginOpts.spritePath, 'custom-name.png'))), 0));
117117
}
@@ -120,6 +120,6 @@ test('should use Promise result provided by book', async (t) => {
120120
[ opts, images, spritesheets ] = await runSpritesmith(t.context.opts, images);
121121
[ opts, images, spritesheets ] = await saveSpritesheets(t.context.opts, images, spritesheets);
122122

123-
t.deepEqual(spritesheets[0].path, 'build/on-save-hook/custom-name.png');
124-
t.truthy(fs.statAsync('./build/on-save-hook/custom-name.png'));
123+
t.deepEqual(spritesheets[0].path, 'test/build/on-save-hook/custom-name.png');
124+
t.truthy(fs.statAsync('./test/build/on-save-hook/custom-name.png'));
125125
});

test/09-map-spritesheet-props.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,27 @@ test.beforeEach((t) => {
2020
});
2121

2222
test('should add coords & spritePath to every image', async (t) => {
23-
const cssContents = await readFileAsync('./fixtures/basic/style.css');
24-
const ast = postcss.parse(cssContents, { from: './fixtures/basic/style.css' });
23+
const cssContents = await readFileAsync('./test/fixtures/basic/style.css');
24+
const ast = postcss.parse(cssContents, { from: './test/fixtures/basic/style.css' });
2525
let images, spritesheets, opts;
2626

27-
t.context.opts.spritePath = './build/basic';
27+
t.context.opts.spritePath = './test/build/basic';
2828

2929
[ opts, images ] = await extractImages(ast, t.context.opts);
3030
[ opts, images, spritesheets ] = await runSpritesmith(t.context.opts, images);
3131
[ opts, images, spritesheets ] = await saveSpritesheets(t.context.opts, images, spritesheets);
3232
[ opts, images, spritesheets ] = await mapSpritesheetProps(t.context.opts, images, spritesheets);
3333

34-
t.deepEqual(images[0].spritePath, 'build/basic/sprite.png');
34+
t.deepEqual(images[0].spritePath, 'test/build/basic/sprite.png');
3535
t.deepEqual(images[0].coords, { x: 0, y: 0, height: 25, width: 25 });
3636
});
3737

3838
test('should add coords & spritePath to every SVG image', async (t) => {
39-
const cssContents = await readFileAsync('./fixtures/svg-basic/style.css');
40-
const ast = postcss.parse(cssContents, { from: './fixtures/svg-basic/style.css' });
39+
const cssContents = await readFileAsync('./test/fixtures/svg-basic/style.css');
40+
const ast = postcss.parse(cssContents, { from: './test/fixtures/svg-basic/style.css' });
4141
let images, spritesheets, opts;
4242

43-
t.context.opts.spritePath = './build/svg-basic';
43+
t.context.opts.spritePath = './test/build/svg-basic';
4444

4545
prepareGroupBy(t.context.opts);
4646
[ opts, images ] = await extractImages(ast, t.context.opts);
@@ -49,6 +49,6 @@ test('should add coords & spritePath to every SVG image', async (t) => {
4949
[ opts, images, spritesheets ] = await saveSpritesheets(t.context.opts, images, spritesheets);
5050
[ opts, images, spritesheets ] = await mapSpritesheetProps(t.context.opts, images, spritesheets);
5151

52-
t.deepEqual(images[0].spritePath, 'build/svg-basic/sprite.svg');
52+
t.deepEqual(images[0].spritePath, 'test/build/svg-basic/sprite.svg');
5353
t.deepEqual(images[0].coords, { x: 0, y: 0, height: 600, width: 600 });
5454
});

test/10-update-references.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ test.beforeEach((t) => {
2121
});
2222

2323
test('should update CSS declarations', async (t) => {
24-
const input = await readFileAsync('./fixtures/basic/style.css');
25-
const expected = await readFileAsync('./expectations/basic/style.css', 'utf8');
26-
const ast = postcss.parse(input, { from: './fixtures/basic/style.css' });
24+
const input = await readFileAsync('./test/fixtures/basic/style.css');
25+
const expected = await readFileAsync('./test/expectations/basic/style.css', 'utf8');
26+
const ast = postcss.parse(input, { from: './test/fixtures/basic/style.css' });
2727
let images, spritesheets, opts, root;
2828

29-
t.context.opts.spritePath = './build/basic';
30-
t.context.opts.stylesheetPath = './build/basic';
29+
t.context.opts.spritePath = './test/build/basic';
30+
t.context.opts.stylesheetPath = './test/build/basic';
3131

3232
[ opts, images ] = await extractImages(ast, t.context.opts);
3333
[ root, opts, images ] = await setTokens(ast, t.context.opts, images);
@@ -40,12 +40,12 @@ test('should update CSS declarations', async (t) => {
4040
});
4141

4242
test('should update CSS declarations with relative paths', async (t) => {
43-
const input = await readFileAsync('./fixtures/relative/style.css');
44-
const expected = await readFileAsync('./expectations/relative/style.css', 'utf8');
45-
const ast = postcss.parse(input, { from: './fixtures/relative/style.css' });
43+
const input = await readFileAsync('./test/fixtures/relative/style.css');
44+
const expected = await readFileAsync('./test/expectations/relative/style.css', 'utf8');
45+
const ast = postcss.parse(input, { from: './test/fixtures/relative/style.css' });
4646
let images, spritesheets, opts, root;
4747

48-
t.context.opts.spritePath = './build/relative';
48+
t.context.opts.spritePath = './test/build/relative';
4949

5050
[ opts, images ] = await extractImages(ast, t.context.opts);
5151
[ root, opts, images ] = await setTokens(ast, t.context.opts, images);
@@ -58,13 +58,13 @@ test('should update CSS declarations with relative paths', async (t) => {
5858
});
5959

6060
test('should use function provided by onUpdateRule hook', async (t) => {
61-
const input = await readFileAsync('./fixtures/basic/style.css');
62-
const expected = await readFileAsync('./expectations/basic-on-update-rule-hook/style.css', 'utf8');
63-
const ast = postcss.parse(input, { from: './fixtures/basic/style.css' });
61+
const input = await readFileAsync('./test/fixtures/basic/style.css');
62+
const expected = await readFileAsync('./test/expectations/basic-on-update-rule-hook/style.css', 'utf8');
63+
const ast = postcss.parse(input, { from: './test/fixtures/basic/style.css' });
6464
let images, spritesheets, opts, root;
6565

66-
t.context.opts.spritePath = './build/basic-on-update-rule-hook';
67-
t.context.opts.stylesheetPath = './build/basic-on-update-rule-hook';
66+
t.context.opts.spritePath = './test/build/basic-on-update-rule-hook';
67+
t.context.opts.stylesheetPath = './test/build/basic-on-update-rule-hook';
6868
t.context.opts.hooks.onUpdateRule = (rule, commentNode, image) => {
6969
const backgroundColorDecl = postcss.decl({
7070
prop: 'background-color',

0 commit comments

Comments
 (0)