Skip to content

Commit caece4e

Browse files
kdmcclelAkryum
authored andcommitted
feat: Add copyUrlOnStart option for clipboardy (#41)
1 parent be28007 commit caece4e

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

docs/guide/configuration.md

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ module.exports = {
4848
const cookieParser = require('cookie-parser')
4949
app.use(cookieParser())
5050
},
51+
// Copy URL to system clipboard on start
52+
copyUrlOnStart: true,
5153
// Function to call after rendering has been completed
5254
onRender: (res, context) => {
5355
res.setHeader(`Cache-Control', 'public, max-age=${context.maxAge}`)

lib/config.js

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ module.exports = {
1818
staticCacheTtl: 1000 * 60 * 60 * 24 * 30,
1919
directives: {},
2020
lruCacheOptions: {},
21+
copyUrlOnStart: true,
2122
onRender: null,
2223
onError: null,
2324
// Paths

lib/dev-server.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ module.exports.setupDevServer = ({ server, templatePath, onUpdate }) => new Prom
131131
function onCompilationCompleted () {
132132
if (firstRun) {
133133
firstRun = false
134-
require('clipboardy').write(url)
135-
copied = chalk.dim('(copied to clipboard)')
136-
} else {
137-
copied = ''
134+
if(config.copyUrlOnStart) {
135+
require('clipboardy').write(url)
136+
copied = chalk.dim('(copied to clipboard)')
137+
}
138138
}
139139

140140
setTimeout(() => {

0 commit comments

Comments
 (0)