mirror of
https://github.com/sunknudsen/privacy-guides.git
synced 2025-02-22 16:53:56 +00:00
Implemented serve and copy-link development features
This commit is contained in:
parent
48a50320a8
commit
3dcffe7cef
2
.env.sample
Normal file
2
.env.sample
Normal file
@ -0,0 +1,2 @@
|
||||
PORT=8080
|
||||
LOCALHOST_PROXY=
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
.env
|
||||
*.code-workspace
|
||||
/node_modules
|
9
.vscode/tasks.json
vendored
9
.vscode/tasks.json
vendored
@ -1,6 +1,15 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"type": "shell",
|
||||
"label": "Copy link",
|
||||
"command": "node ./tasks/copy-link.js \"${selectedText}\"",
|
||||
"presentation": {
|
||||
"reveal": "silent"
|
||||
},
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"label": "Insert YouTube player",
|
||||
|
16
index.js
Normal file
16
index.js
Normal file
@ -0,0 +1,16 @@
|
||||
"use strict"
|
||||
|
||||
import express from "express"
|
||||
|
||||
const app = express()
|
||||
|
||||
app.use(
|
||||
express.static(".", {
|
||||
dotfiles: "ignore",
|
||||
index: false,
|
||||
})
|
||||
)
|
||||
|
||||
const server = app.listen(process.env.PORT ?? 8080, () => {
|
||||
console.info(`Server listening on port ${server.address().port}`)
|
||||
})
|
1164
package-lock.json
generated
1164
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -11,6 +11,7 @@
|
||||
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"serve": "node index.js",
|
||||
"ncu": "ncu --target minor --upgrade"
|
||||
},
|
||||
"author": "Sun Knudsen <hello@sunknudsen.com>",
|
||||
@ -20,7 +21,11 @@
|
||||
},
|
||||
"homepage": "https://github.com/sunknudsen/privacy-guides#readme",
|
||||
"devDependencies": {
|
||||
"@types/express": "^4.17.13",
|
||||
"@types/fs-extra": "^9.0.13",
|
||||
"clipboardy": "^3.0.0",
|
||||
"dotenv": "^16.0.0",
|
||||
"express": "^4.17.2",
|
||||
"fs-extra": "^10.0.0",
|
||||
"npm-check-updates": "^12.3.0",
|
||||
"readdirp": "^3.6.0",
|
||||
|
21
tasks/copy-link.js
Normal file
21
tasks/copy-link.js
Normal file
@ -0,0 +1,21 @@
|
||||
"use strict"
|
||||
|
||||
import "dotenv/config"
|
||||
|
||||
import clipboard from "clipboardy"
|
||||
|
||||
if (process.argv.length !== 3 || !process.argv[2].match(/http(s)?:\/\//)) {
|
||||
console.info("Usage: node copy-link.js selectedText")
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
var text = process.argv[2]
|
||||
|
||||
if (process.env.LOCALHOST_PROXY) {
|
||||
text = text.replace(
|
||||
"https://raw.githubusercontent.com/sunknudsen/privacy-guides/master",
|
||||
process.env.LOCALHOST_PROXY
|
||||
)
|
||||
}
|
||||
|
||||
clipboard.write(text)
|
Loading…
x
Reference in New Issue
Block a user