Skip to content

Commit

Permalink
Switch crafty-preset-images-simple to esm
Browse files Browse the repository at this point in the history
  • Loading branch information
onigoetz committed Aug 7, 2023
1 parent e99f8bf commit 0e6a4fc
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 11 deletions.
4 changes: 2 additions & 2 deletions packages/crafty-preset-images-simple/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const path = require("path");
import path from "path";

module.exports = {
export default {
defaultConfig() {
return {
bundleTypes: { img: "images" },
Expand Down
1 change: 1 addition & 0 deletions packages/crafty-preset-images-simple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"repository": "https://github.com/swissquote/crafty.git",
"description": "Compress images with Crafty",
"license": "Apache-2.0",
"type": "module",
"publishConfig": {
"registry": "https://registry.npmjs.org",
"access": "public"
Expand Down
14 changes: 9 additions & 5 deletions packages/crafty-runner-gulp/src/index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
const StreamHandler = require("./StreamHandler");
const Gulp = require("./Gulp.js");

let gulp;
const gulpSymbol = Symbol.for("gulp");

function getGulp(crafty) {
return crafty[gulpSymbol];
}

module.exports = {
init(crafty) {
gulp = new Gulp(crafty);
StreamHandler.init(crafty, gulp);
crafty[gulpSymbol] = new Gulp(crafty);
StreamHandler.init(crafty, getGulp(crafty));
},
bundleCreator(/*crafty*/) {
return {
__gulp(craftyAgain, bundle, creator) {
creator(craftyAgain, bundle, gulp, StreamHandler);
creator(craftyAgain, bundle, getGulp(craftyAgain), StreamHandler);
}
};
},
tasks(crafty) {
crafty.runAllSync("gulp", crafty, gulp, StreamHandler);
crafty.runAllSync("gulp", crafty, getGulp(crafty), StreamHandler);
}
};
1 change: 0 additions & 1 deletion packages/crafty/src/bin.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ configuration.getCrafty(
// Get all possible commands
const commands = getCommands(crafty);


try {
// Run the user selected command
const exitCode = await cli(crafty, commands)
Expand Down
5 changes: 2 additions & 3 deletions packages/integration/__tests__/crafty-preset-images-simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ test("Loads crafty-preset-images-simple and does not register gulp tasks", async
t.deepEqual(Object.keys(crafty.undertaker._registry.tasks()), []);
});

test("Fails if both crafty-preset-images-simple and crafty-preset-images-simple are loaded", async t => {
test("Fails if both crafty-preset-images and crafty-preset-images-simple are loaded", async t => {
const crafty = await getCrafty(
[
"@swissquote/crafty-preset-images",
Expand All @@ -39,8 +39,7 @@ test("Fails if both crafty-preset-images-simple and crafty-preset-images-simple
t.truthy(loadedPresets.includes("@swissquote/crafty-runner-gulp"));

t.throws(() => crafty.createTasks(), {
message:
"Failed registering 'crafty-preset-images-simple' a task with this name already exists"
message: /a task with this name already exists/
});
});

Expand Down

0 comments on commit 0e6a4fc

Please sign in to comment.