Skip to content

Commit

Permalink
fix: don't provide general file export logic
Browse files Browse the repository at this point in the history
  • Loading branch information
roperzh committed Nov 14, 2019
1 parent 3dd827d commit 7f5e3f1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 36 deletions.
16 changes: 3 additions & 13 deletions packages/designfile/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,10 @@ Export assets from design files, we currently support Sketch, Illustrator and Fi

### Usage

You can let the module figure out the correct parser for you:

```js
import {exportSVG, canParse} from '@livedesigner/designfile';
import {figma} from '@livedesigner/designfile/lib';

if (canParse('my/design/file.ai')) {
await exportSVG('my/design/file.ai', 'out/folder');
if (figma.canParse(source)) {
await figma.exportSVG(source, 'out/folder');
}
```

or you can use any of the parsers individually:

```js
import {figma} from '@livedesigner/designfile/lib/exporters/figma';

await figma.exportSVG('https://figma.com/file/<key>/<title>', 'out/folder');
```
26 changes: 3 additions & 23 deletions packages/designfile/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,3 @@
import {figma} from './exporters/figma';
import {illustrator} from './exporters/illustrator';
import {sketch} from './exporters/sketch';

const ENABLED_EXPORTERS = [figma, illustrator, sketch];

const findExporter = (source: string) => {
return ENABLED_EXPORTERS.find((exporter) => exporter.canParse(source));
};

export const canParse = (source: string): boolean => {
return Boolean(findExporter(source));
};

export const exportSVG = async (source: string, out: string) => {
const exporter = findExporter(source);

if (exporter) {
return exporter.exportSVG(source, out);
}

return false;
};
export {figma} from './exporters/figma';
export {illustrator} from './exporters/illustrator';
export {sketch} from './exporters/sketch';

0 comments on commit 7f5e3f1

Please sign in to comment.