-
Notifications
You must be signed in to change notification settings - Fork 820
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change the interface of getSketchVersion()
- Loading branch information
1 parent
0071286
commit 3aab5da
Showing
6 changed files
with
19 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,11 @@ | ||
import { FileFormat1 as FileFormat } from '@sketch-hq/sketch-file-format-ts'; | ||
import { LayoutInfo } from '../types'; | ||
import { getSketchVersion } from '../utils/getSketchVersion'; | ||
import isRunningInSketch from '../utils/isRunningInSketch'; | ||
import sketchMethod from './sketchImpl/makeSvgLayer'; | ||
import nodeMethod from './nodeImpl/makeSvgLayer'; | ||
|
||
const makeSvgLayer = (layout: LayoutInfo, name: string, svg: string): FileFormat.Group => { | ||
if (getSketchVersion() === 'NodeJS') { | ||
return nodeMethod(layout, name, svg); | ||
} | ||
return sketchMethod(layout, name, svg); | ||
return isRunningInSketch() ? sketchMethod(layout, name, svg) : nodeMethod(layout, name, svg); | ||
}; | ||
|
||
export default makeSvgLayer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
export function getSketchVersion(): number | 'NodeJS' { | ||
if (typeof NSBundle !== 'undefined') { | ||
return parseFloat(NSBundle.mainBundle().infoDictionary().CFBundleShortVersionString); | ||
} | ||
return 'NodeJS'; | ||
export default function getSketchVersion(): string { | ||
return typeof NSBundle !== 'undefined' | ||
? NSBundle.mainBundle().infoDictionary().CFBundleShortVersionString | ||
: ''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import getSketchVersion from './getSketchVersion'; | ||
|
||
export default function isRunningInSketch() { | ||
return getSketchVersion() !== ''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { getSketchVersion } from './getSketchVersion'; | ||
import SketchStyles from '../jsonUtils/sketchImpl/sharedTextStyles'; | ||
import NodeStyles from '../jsonUtils/nodeImpl/sharedTextStyles'; | ||
import isRunningInSketch from './isRunningInSketch'; | ||
|
||
export default getSketchVersion() === 'NodeJS' ? new NodeStyles() : new SketchStyles(); | ||
export default isRunningInSketch() ? new NodeStyles() : new SketchStyles(); |