-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
54 additions
and
2 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
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,30 @@ | ||
import { dirname, resolve } from 'path' | ||
import fs from 'fs-extra' | ||
import { ResolvedSlidevOptions } from './options' | ||
|
||
function resolveDrawingsPath(options: ResolvedSlidevOptions): string | undefined { | ||
if (options.data.config.persistDrawings === false) | ||
return undefined | ||
|
||
return options.data.config.persistDrawings === true | ||
? resolve(dirname(options.entry), '.slidev/drawings.json') | ||
: options.data.config.persistDrawings | ||
} | ||
|
||
export async function loadDrawings(options: ResolvedSlidevOptions) { | ||
const path = resolveDrawingsPath(options) | ||
|
||
if (path && fs.existsSync(path)) | ||
return await fs.readJson(path) | ||
else | ||
return {} | ||
} | ||
|
||
export async function writeDarwings(options: ResolvedSlidevOptions, drawing: any) { | ||
const path = resolveDrawingsPath(options) | ||
if (!path) | ||
return | ||
|
||
await fs.ensureDir(dirname(path)) | ||
return await fs.writeJSON(path, drawing, { spaces: 2 }) | ||
} |
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
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