diff --git a/plugins/plugin-notches/build.mjs b/plugins/plugin-notches/build.mjs index 9d1da1994da..0f283af1c6d 100644 --- a/plugins/plugin-notches/build.mjs +++ b/plugins/plugin-notches/build.mjs @@ -14,7 +14,7 @@ const banner = `/** const options = { banner: { js: banner }, bundle: true, - entryPoints: ['src/index.js'], + entryPoints: ['src/index.mjs'], format: 'esm', outfile: 'dist/index.mjs', external: ["@freesewing"], diff --git a/plugins/plugin-notches/package.json b/plugins/plugin-notches/package.json index ccf13226d36..8ae5f10f221 100644 --- a/plugins/plugin-notches/package.json +++ b/plugins/plugin-notches/package.json @@ -38,7 +38,7 @@ "vbuild": "VERBOSE=1 node --experimental-json-modules build.mjs", "lab": "cd ../../sites/lab && yarn start", "tips": "node ../../scripts/help.mjs", - "prettier": "npx prettier --write 'src/*.js' 'tests/*.mjs'", + "prettier": "npx prettier --write 'src/*.mjs' 'tests/*.mjs'", "testci": "npx mocha tests/*.test.mjs --reporter ../../tests/reporters/terse.js", "cibuild_step1": "node --experimental-json-modules build.mjs" }, diff --git a/plugins/plugin-notches/src/index.js b/plugins/plugin-notches/src/index.js deleted file mode 100644 index a3151e9d7bb..00000000000 --- a/plugins/plugin-notches/src/index.js +++ /dev/null @@ -1,17 +0,0 @@ -import pkg from '../package.json' - -const notches = - '' - -export default { - name: pkg.name, - version: pkg.version, - hooks: { - preRender: function (svg) { - if (svg.attributes.get('freesewing:plugin-notches') === false) { - svg.defs += notches - svg.attributes.set('freesewing:plugin-notches', pkg.version) - } - }, - }, -} diff --git a/plugins/plugin-notches/src/index.mjs b/plugins/plugin-notches/src/index.mjs new file mode 100644 index 00000000000..e2214c8c3df --- /dev/null +++ b/plugins/plugin-notches/src/index.mjs @@ -0,0 +1,26 @@ +import { name, version } from '../package.json' + +const notches = ` + + + + + + + +` + +export const plugin = { + name, + version, + hooks: { + preRender: function (svg) { + if (svg.defs.indexOf(`id="notch"`) === -1) svg.defs += notches + }, + }, +} + +// More specifically named exports +export const notchesPlugin = plugin +export const pluginNotches = plugin + diff --git a/plugins/plugin-notches/tests/plugin.test.mjs b/plugins/plugin-notches/tests/plugin.test.mjs index 9cef12c526d..0f437e0b89e 100644 --- a/plugins/plugin-notches/tests/plugin.test.mjs +++ b/plugins/plugin-notches/tests/plugin.test.mjs @@ -1,10 +1,10 @@ import chai from 'chai' -import freesewing from '@freesewing/core' -import plugin from '../dist/index.mjs' +import { Pattern } from '@freesewing/core' +import { plugin } from '../dist/index.mjs' const expect = chai.expect -const pattern = new freesewing.Pattern().use(plugin) +const pattern = new Pattern().use(plugin) pattern.draft().render() describe('Notches Plugin Test', () => { @@ -17,13 +17,13 @@ describe('Notches Plugin Test', () => { }) it("Draws a notch on an anchor point", () => { - let pattern = new freesewing.Pattern() + const pattern = new Pattern() pattern.use(plugin) pattern.parts.test = new pattern.Part() - let { Point, snippets, Snippet } = pattern.parts.test.shorthand() + const { Point, snippets, Snippet } = pattern.parts.test.shorthand() snippets.button = new Snippet('notch', new Point(10,20)) pattern.render() - let c = pattern.svg + const c = pattern.svg expect(c.layout.test.svg).to.contain('