From e458df78d9b261c2aae1c8505b8b666e74418b35 Mon Sep 17 00:00:00 2001 From: sy-records <52o@qq52o.cn> Date: Wed, 19 Aug 2020 09:23:05 +0800 Subject: [PATCH 1/9] feat: Added asking whether to rewrite files --- lib/commands/init.js | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/lib/commands/init.js b/lib/commands/init.js index 91a29be..9d80ac6 100644 --- a/lib/commands/init.js +++ b/lib/commands/init.js @@ -1,9 +1,8 @@ -'use strict' - const fs = require('fs') const cp = require('cp-file').sync const chalk = require('chalk') -const {cwd, exists, pkg, pwd, read, resolve} = require('../util') +const inquirer = require('inquirer') +const { cwd, exists, pkg, pwd, read, resolve } = require('../util') const replace = function (file, tpl, replace) { fs.writeFileSync(file, read(file).replace(tpl, replace), 'utf-8') @@ -19,6 +18,36 @@ module.exports = function (path = '', local, theme) { '\n' path = cwd(path || '.') + + if (exists(path)) { + console.log(chalk.red(`${path} `) + 'already exists.') + + inquirer + .prompt([ + { + type: 'confirm', + name: 'rewrite', + message: 'Are you sure you want to rewrite it?', + default: true, + } + ]) + .then(answers => { + if (answers.rewrite === false) { + return process.exit(0) + } + + createFile(path, local, theme) + console.log(msg) + }) + + return false + } + + createFile(path, local, theme) + console.log(msg) +} + +function createFile(path, local, theme) { const target = file => resolve(path, file) const readme = exists(cwd('README.md')) || pwd('template/README.md') let main = pwd('template/index.html') @@ -63,6 +92,4 @@ module.exports = function (path = '', local, theme) { .replace(/^git\+/g, '') replace(target(filename), 'repo: \'\'', `repo: '${repo}'`) } - - console.log(msg) } From b82d643981726cdfd2b10abe6c951f176fdb971d Mon Sep 17 00:00:00 2001 From: sy-records <52o@qq52o.cn> Date: Wed, 19 Aug 2020 09:24:15 +0800 Subject: [PATCH 2/9] fix typo --- lib/commands/init.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/commands/init.js b/lib/commands/init.js index 9d80ac6..12af3fe 100644 --- a/lib/commands/init.js +++ b/lib/commands/init.js @@ -1,3 +1,5 @@ +'use strict' + const fs = require('fs') const cp = require('cp-file').sync const chalk = require('chalk') From 32e2874bbcf85db36fa81d19eb7e3eed17dbca1b Mon Sep 17 00:00:00 2001 From: sy-records <52o@qq52o.cn> Date: Wed, 19 Aug 2020 09:30:25 +0800 Subject: [PATCH 3/9] fix ci --- lib/commands/init.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/commands/init.js b/lib/commands/init.js index 12af3fe..1a4a656 100644 --- a/lib/commands/init.js +++ b/lib/commands/init.js @@ -4,7 +4,7 @@ const fs = require('fs') const cp = require('cp-file').sync const chalk = require('chalk') const inquirer = require('inquirer') -const { cwd, exists, pkg, pwd, read, resolve } = require('../util') +const {cwd, exists, pkg, pwd, read, resolve} = require('../util') const replace = function (file, tpl, replace) { fs.writeFileSync(file, read(file).replace(tpl, replace), 'utf-8') @@ -30,7 +30,7 @@ module.exports = function (path = '', local, theme) { type: 'confirm', name: 'rewrite', message: 'Are you sure you want to rewrite it?', - default: true, + default: true } ]) .then(answers => { From 39768846a3d4a20474f2b2e3cff6a8cbaf4d0deb Mon Sep 17 00:00:00 2001 From: sy-records <52o@qq52o.cn> Date: Wed, 19 Aug 2020 09:36:02 +0800 Subject: [PATCH 4/9] fix ci --- package-lock.json | 203 ++++++++++++++++++++++++++++++++++++++++++++-- package.json | 1 + 2 files changed, 195 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index 93e520c..468bd18 100644 --- a/package-lock.json +++ b/package-lock.json @@ -601,6 +601,21 @@ } } }, + "ansi-escapes": { + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.1.tgz", + "integrity": "sha512-JWF7ocqNrp8u9oqpgV+wH5ftbt+cfvv+PTjOvKLT3AdYly/LmORARfEVT1iyjwN+4MqE5UmVKoAdIBqeoCHgLA==", + "requires": { + "type-fest": "^0.11.0" + }, + "dependencies": { + "type-fest": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.11.0.tgz", + "integrity": "sha512-OdjXJxnCN1AvyLSzeKIgXTXxV+99ZuXl3Hpo9XpJAv9MBcHrrJOQ5kV7ypXOuQie+AmWG25hLbiKdwYTifzcfQ==" + } + } + }, "ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", @@ -1670,6 +1685,11 @@ "supports-color": "^5.3.0" } }, + "chardet": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", + "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==" + }, "chokidar": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.3.1.tgz", @@ -3898,6 +3918,16 @@ } } }, + "external-editor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz", + "integrity": "sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==", + "requires": { + "chardet": "^0.7.0", + "iconv-lite": "^0.4.24", + "tmp": "^0.0.33" + } + }, "fast-deep-equal": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", @@ -5099,6 +5129,161 @@ "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==" }, + "inquirer": { + "version": "7.3.3", + "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.3.3.tgz", + "integrity": "sha512-JG3eIAj5V9CwcGvuOmoo6LB9kbAYT8HXffUl6memuszlwDC/qvFAJw49XJ5NROSFNPxp3iQg1GqkFhaY/CR0IA==", + "requires": { + "ansi-escapes": "^4.2.1", + "chalk": "^4.1.0", + "cli-cursor": "^3.1.0", + "cli-width": "^3.0.0", + "external-editor": "^3.0.3", + "figures": "^3.0.0", + "lodash": "^4.17.19", + "mute-stream": "0.0.8", + "run-async": "^2.4.0", + "rxjs": "^6.6.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0", + "through": "^2.3.6" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==" + }, + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", + "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "cli-cursor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", + "integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==", + "requires": { + "restore-cursor": "^3.1.0" + } + }, + "cli-width": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-3.0.0.tgz", + "integrity": "sha512-FxqpkPPwu1HjuN93Omfm4h8uIanXofW0RxVEW3k5RKx+mJJYSthzNhp32Kzxxy3YAEZ/Dc/EWN1vZRY0+kOhbw==" + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + }, + "figures": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz", + "integrity": "sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg==", + "requires": { + "escape-string-regexp": "^1.0.5" + } + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" + }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==" + }, + "mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==" + }, + "onetime": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "requires": { + "mimic-fn": "^2.1.0" + } + }, + "restore-cursor": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", + "integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==", + "requires": { + "onetime": "^5.1.0", + "signal-exit": "^3.0.2" + } + }, + "run-async": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz", + "integrity": "sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ==" + }, + "rxjs": { + "version": "6.6.2", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.2.tgz", + "integrity": "sha512-BHdBMVoWC2sL26w//BCu3YzKT4s2jip/WhwsGEDmeKYBhKDZeYezVUnHatYB7L85v5xs0BAQmg6BEYJEKxBabg==", + "requires": { + "tslib": "^1.9.0" + } + }, + "string-width": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz", + "integrity": "sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==", + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" + } + }, + "strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "requires": { + "ansi-regex": "^5.0.0" + } + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, "interpret": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.4.0.tgz", @@ -5830,8 +6015,7 @@ "lodash": { "version": "4.17.19", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.19.tgz", - "integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==", - "dev": true + "integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==" }, "lodash._reinterpolate": { "version": "3.0.0", @@ -6140,6 +6324,11 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, + "mute-stream": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", + "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==" + }, "natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", @@ -6359,8 +6548,7 @@ "os-tmpdir": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", - "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", - "dev": true + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=" }, "p-cancelable": { "version": "1.1.0", @@ -7766,8 +7954,7 @@ "through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", - "dev": true + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" }, "through2": { "version": "3.0.2", @@ -7800,7 +7987,6 @@ "version": "0.0.33", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", - "dev": true, "requires": { "os-tmpdir": "~1.0.2" } @@ -7850,8 +8036,7 @@ "tslib": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", - "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==", - "dev": true + "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==" }, "tweezer.js": { "version": "1.5.0", diff --git a/package.json b/package.json index ffd6efb..fa80df0 100644 --- a/package.json +++ b/package.json @@ -56,6 +56,7 @@ "docsify-server-renderer": ">=4", "fs-extra": "^8.1.0", "get-port": "^5.0.0", + "inquirer": "^7.3.3", "livereload": "^0.9.1", "lru-cache": "^5.1.1", "open": "^6.4.0", From afb83f4511d53403adbe36cf7e9d4aee478f6728 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=94=81?= <52o@qq52o.cn> Date: Wed, 19 Aug 2020 10:14:12 +0800 Subject: [PATCH 5/9] Update init.js --- lib/commands/init.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/commands/init.js b/lib/commands/init.js index 1a4a656..7c5b8e6 100644 --- a/lib/commands/init.js +++ b/lib/commands/init.js @@ -22,7 +22,7 @@ module.exports = function (path = '', local, theme) { path = cwd(path || '.') if (exists(path)) { - console.log(chalk.red(`${path} `) + 'already exists.') + console.log(chalk.red(`${path}`) + ' already exists.') inquirer .prompt([ From 6448a4e0f114a1f9cbd8b4f36e9df085388627cd Mon Sep 17 00:00:00 2001 From: sy-records <52o@qq52o.cn> Date: Thu, 20 Aug 2020 11:35:25 +0800 Subject: [PATCH 6/9] add tests --- .gitignore | 1 + e2e/index.js | 10 ++++++++++ e2e/index.js.md | 15 +++++++++++++++ e2e/index.js.snap | Bin 609 -> 778 bytes lib/commands/init.js | 10 +++++----- 5 files changed, 31 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 6746c28..725b7b1 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ node_modules/ yarn.lock bin/ +test_docs/ diff --git a/e2e/index.js b/e2e/index.js index 5fa8233..22a43cd 100644 --- a/e2e/index.js +++ b/e2e/index.js @@ -25,3 +25,13 @@ test('rejects promise due to error on passing in an unknown command', async t => const {stderr} = await execa(rootCommand, ['junkcmd'], {reject: false}) t.snapshot(stderr) }) + +test('init the docs directory', async t => { + const {stdout} = await execa(rootCommand, ['init', './test_docs'], {reject: false}) + t.snapshot(stdout) +}) + +test('init the docs directory twice', async t => { + const {stdout} = await execa(rootCommand, ['init', './test_docs'], {reject: false, input: 'n'}) + t.snapshot(stdout) +}) diff --git a/e2e/index.js.md b/e2e/index.js.md index 2fe1595..ad956d1 100644 --- a/e2e/index.js.md +++ b/e2e/index.js.md @@ -4,6 +4,21 @@ The actual snapshot is saved in `index.js.snap`. Generated by [AVA](https://ava.li). +## init the docs directory + +> Snapshot 1 + + `␊ + Initialization succeeded! Please run docsify serve ./test_docs␊ + ` + +## init the docs directory twice + +> Snapshot 1 + + `./test_docs already exists.␊ + ? Are you sure you want to rewrite it? (Y/n) [45D[45C[2K[G? Are you sure you want to rewrite it? (Y/n) n[46D[46C[2K[G? Are you sure you want to rewrite it? No[41D[41C` + ## rejects promise due to error on passing in an unknown command > Snapshot 1 diff --git a/e2e/index.js.snap b/e2e/index.js.snap index 3f8aa78bce559defd06fed065f5d60f423700d4e..848a858084d0bc9c7faa3d4cf86fbf8857e40673 100644 GIT binary patch literal 778 zcmV+l1NHntRzV<BZeeh9Xm4~Nb}|YA06*gMGxY366jwQb`<Zi9nIDS?00000000B+ zl}|_%Q5?tLxQIE2usZZ-Nq*L)!kx)5q0K+l8X|$pu1m=#_IBpEJ32dWnD=%!E&4+d z-6V{N@K9<0@SGP557Ei&R9gfQ)V-if9t?Ujj<$A?*7H7?W%=^`e&_w>ec%-kLYq*) z*)#v~#qOz)*|P9p=i+M#xvO40%C~2D{>RMZ=KMr#?)lp>$y3KF5Gq`+UMd{Dx2xv~ z>`<%D+?G7`vv@9VOD30`JC$E=PCmLo56nuQS{*>BuYLCS^tq+Fx$Un4bpzvZ$y1vu z5t{l`bN9o<*<k)%>gUV%mqeSZYE=l4#hItE(Lmq*@AcC)6D`*yPo1ttNRREkdTabk zZtL8y#}7|0T#-EWhKx`ERe2Lgm1v7pE9+Ea#^6XuGY!ZQhZ)og%K(i^qtYN3dn<Y? z;tZ!q82kt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AmpU&sY2mNV)R!^%w^I9fYtNQGY*zz>iV?LY!y=ur5Z1K zFrRmcALbzMLUb&bbs$pUD5qvK<`YcoabWU!DzlvgCJNA2V5@G95~xoxrxg$?u}l`? zN*Rh`p^yx`AdIFb-Ii^5Y)3nsE84WmCvD=hFnXdtJ#jlM*o){dEZFKN3jr3A@It9P zTQO%YS1U8K(?-zH^(tMYtV03wX54%c7Fu-C2^#x2s-zsH9399}?TTrZ%{q+kk|ZF+ vLXd_5SJhyGfCz~b?F)m`17#m#!zp4ZVh13W!ji&rXjuLM>BixV{|Nv9*ia>v diff --git a/lib/commands/init.js b/lib/commands/init.js index 7c5b8e6..78e48a0 100644 --- a/lib/commands/init.js +++ b/lib/commands/init.js @@ -19,10 +19,10 @@ module.exports = function (path = '', local, theme) { chalk.inverse(`docsify serve ${path}`) + '\n' - path = cwd(path || '.') + const cwdPath = cwd(path || '.') - if (exists(path)) { - console.log(chalk.red(`${path}`) + ' already exists.') + if (exists(cwdPath)) { + console.log(chalk.red(`${path || '.'}`) + ' already exists.') inquirer .prompt([ @@ -38,14 +38,14 @@ module.exports = function (path = '', local, theme) { return process.exit(0) } - createFile(path, local, theme) + createFile(cwdPath, local, theme) console.log(msg) }) return false } - createFile(path, local, theme) + createFile(cwdPath, local, theme) console.log(msg) } From e580505c4b83f32d46222ba0f35dedf7ffcb5b96 Mon Sep 17 00:00:00 2001 From: sy-records <52o@qq52o.cn> Date: Thu, 20 Aug 2020 11:44:19 +0800 Subject: [PATCH 7/9] update fix ci fix ci fix ci --- e2e/index.js | 5 +++-- e2e/index.js.md | 2 +- e2e/index.js.snap | Bin 778 -> 781 bytes 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/e2e/index.js b/e2e/index.js index 22a43cd..6822f5f 100644 --- a/e2e/index.js +++ b/e2e/index.js @@ -27,11 +27,12 @@ test('rejects promise due to error on passing in an unknown command', async t => }) test('init the docs directory', async t => { - const {stdout} = await execa(rootCommand, ['init', './test_docs'], {reject: false}) + // If you get `./test_docs already exists.`, delete the test_docs directory manually. + const {stdout} = await execa(rootCommand, ['init', './test_docs'], {reject: false, timeout: 3000}) t.snapshot(stdout) }) test('init the docs directory twice', async t => { - const {stdout} = await execa(rootCommand, ['init', './test_docs'], {reject: false, input: 'n'}) + const {stdout} = await execa(rootCommand, ['init', './'], {reject: false, input: 'n'}) t.snapshot(stdout) }) diff --git a/e2e/index.js.md b/e2e/index.js.md index ad956d1..cdee05a 100644 --- a/e2e/index.js.md +++ b/e2e/index.js.md @@ -16,7 +16,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 - `./test_docs already exists.␊ + `./ already exists.␊ ? Are you sure you want to rewrite it? (Y/n) [45D[45C[2K[G? Are you sure you want to rewrite it? (Y/n) n[46D[46C[2K[G? Are you sure you want to rewrite it? No[41D[41C` ## rejects promise due to error on passing in an unknown command diff --git a/e2e/index.js.snap b/e2e/index.js.snap index 848a858084d0bc9c7faa3d4cf86fbf8857e40673..356df169edb9e7e11d95c108148b28f0819611a2 100644 GIT binary patch literal 781 zcmV+o1M>VqRzV<BZeeh9Xm4~Nb}|YA06Pv<8Ck11_X79KQ8@LFFCU8t00000000B+ zmQ73(K^TT-K?L_;P-FaQBp-TFLwCghiIpF<7(z^dv@}X8!R_wQF6{1XcBZZ1fAru@ z4aOM5K?VQfSuS8W5Kjb8ipGnHp1f${MGlxavlMJE#2&nLlHD|KzW4p+n|-#~MTAfl zQog>>=6_60Y|f5HXJ5U&B_Xl&GKBitr+>dZw_H2BW3Ie*U@Rv2>g^2(UD=jMEPMAV zzTBL6a)BJ2mV9-FUz4Az?|&FS8_2#({(SxZ@?FVSzimXQ+}k_<ac0kC&}vzDv}@^& z<g42&5n8;lX?gMJgWWyPV5eGnhI@pn^UH|tyLM;nb7t%8ucwbsFI<&;wXq5zyfpPZ zI$GZM@O$0M>hYHAlCNHpc^_2iPasvGEoHrBF{&kT2n?cAb8rNjO~+&xDfTkB6`Ea* zrCMb<Ol(_o3>uPQtx(iKTom*JK-j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glTxQ2cJh&Tju!oVVV&rxLb zx>lXhtOX|3u(_-|z$w@c$r&QZ3{I5dB*zZ-Hvte^_774AVzH<!cbGIOYPxMM#&cg7 z3Z;o@*Fz``?uw;p9$W=VS&1a2Cc##}SLlB{(V6oLeFdy+CMkAPN}=3NwQPo19CQCb z(wy5Ytg8ONLrh5-Je^G{23^tq&*h%9=qEX1Qrmq+al7x<Xy$K4aZpW)FR5lQ<HS)T z-Ce!W&J*$8&aMt6qswyQWHj0x?T3Saos_qI1~z7l=nC|R!59H%6U{v@4B9d%Yj8X! zcM4PtY#O89;J~t)Mu<-Ix|IS)K(Q7VMHMvh0S~1O!(Cg3yA1a_aF<~z!?H10j+9|3 z!?NzR8MlTlnzvRj%`gmQtzqpSj^3c6iw>|UaL`A9oHrO}irfar9RedXE3QocPaa#` zJ$r}b9dYbn@HW`jr&{|Vm}orQ?*2rAi9@G?iH?%emPj_a@um{vT~ve`++;)K4<iOB I>0Ao{0M*5IVE_OC From 1644ba5747cbf5dbfa0351ea4f682dbcde5be28a Mon Sep 17 00:00:00 2001 From: sy-records <52o@qq52o.cn> Date: Thu, 20 Aug 2020 14:18:40 +0800 Subject: [PATCH 8/9] change inquirer to enquirer --- e2e/index.js.md | 3 +- e2e/index.js.snap | Bin 781 -> 817 bytes lib/commands/init.js | 17 ++-- package-lock.json | 214 +++++-------------------------------------- package.json | 2 +- 5 files changed, 31 insertions(+), 205 deletions(-) diff --git a/e2e/index.js.md b/e2e/index.js.md index cdee05a..162a2ee 100644 --- a/e2e/index.js.md +++ b/e2e/index.js.md @@ -17,7 +17,8 @@ Generated by [AVA](https://ava.li). > Snapshot 1 `./ already exists.␊ - ? Are you sure you want to rewrite it? (Y/n) [45D[45C[2K[G? Are you sure you want to rewrite it? (Y/n) n[46D[46C[2K[G? Are you sure you want to rewrite it? No[41D[41C` + [?25l[36m?[39m [1mAre you sure you want to rewrite it?[22m [2m(y/N)[22m [2m›[22m [36mfalse[39m[10D[2K[1G[32m✔[39m [1mAre you sure you want to rewrite it?[22m [2m(y/N)[22m [2m·[22m [32mfalse[39m[4D␊ + [?25h` ## rejects promise due to error on passing in an unknown command diff --git a/e2e/index.js.snap b/e2e/index.js.snap index 356df169edb9e7e11d95c108148b28f0819611a2..eaff9de8d3c0da309e4f638a5a3dc0a987f234be 100644 GIT binary patch literal 817 zcmV-11J3+GRzV<BZeeh9Xm4~Nb}|YA07kZ4b52~y?)as!i?CUG;~$F%00000000B+ zR8L40Q5=5bCgvQ%>d+rae%7VJozcw%%|DeJB7w@TQnHD?oqf8aGxL^tZ+BY@GwRSy zLWu|umG%$M8Dt?8ox)CK(Iv1;r-CkdFzC%V>h47}I_`rRX1@8}_j|wjK7I=bq3y_L zAAI-u<$)=`(J+61-_lzNIjcfk%D1QZ-OriH9qEbi+_U$il8cTOAar$iG`eixE?m4h z`S3D5IxD&8thlDWl-&6=aiKK*q5s#bkHh1Vi+<mR(87)4<%JV>_jf#oy=u{U@x?)F z3K1epGf%=pzV3TJDyB;&8m>z&I$VTMcX0O4^u^`!xjk=u<-KEFl8a6kBNPiCx^`>q zYiifr??(^L&5uYfIwK?GLq%=}QX$$YmB}%xF}*M2*9;v}#AZ6R>STawrCO<yv$+MG z1zimHlREIWK)r71{0bv>iZnuf0`qvIEH_ir#8!+sBCAA)2N8$R0|3o7!JII#NZMs& z5nZh{W+-WaK{afw;5Kjy37e#Jv61PVDA_wXwz+o*fba^xkJ=Cphh(|Mpiv>yp5UTA zr=Z^-Cq|+I{BdwrI8M{xAh4AciBf71Z1uQ;-p>=7DNoQtz)G4?ahk0N%0a3nO=5A( zJwxK0Cs>`TdJPXSrC;aqWK_}VDz-V6<FwExDPqusQzBd4V{6o0m&o3zM#Z00P0Tp4 z)#moL&QR;=uFlrB7R8Loa^y@X)E?@AO2Br%dwd27%ovF&&><RQ1XzM-j$atGm7x4{ z9Lw@?%*SzqIOYWFq}(b@*Ri1wxh()oY8oLi5-VR#rY-EvHC|CgE_kmSik#@x=A)O7 z-iDK~%Nn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ffp2txrghWv}Lu|kYr~uPB zq^O`-95Q1B@OhIms>p3{+`}+J(mXr&Bda+~5ar>l$6*4KwZZ;A)j0rxctc~mxP=4p z!>0oAj-uQScQy%oQ<3&A!cFzUSsyN#=t$|sE4_H@el*0KVTWX$wNHi+45gi6-8TLJ LM=x@3Qwsn9byaeT diff --git a/lib/commands/init.js b/lib/commands/init.js index 78e48a0..5d76cb8 100644 --- a/lib/commands/init.js +++ b/lib/commands/init.js @@ -3,7 +3,7 @@ const fs = require('fs') const cp = require('cp-file').sync const chalk = require('chalk') -const inquirer = require('inquirer') +const {prompt} = require('enquirer') const {cwd, exists, pkg, pwd, read, resolve} = require('../util') const replace = function (file, tpl, replace) { @@ -24,15 +24,11 @@ module.exports = function (path = '', local, theme) { if (exists(cwdPath)) { console.log(chalk.red(`${path || '.'}`) + ' already exists.') - inquirer - .prompt([ - { - type: 'confirm', - name: 'rewrite', - message: 'Are you sure you want to rewrite it?', - default: true - } - ]) + prompt({ + type: 'confirm', + name: 'rewrite', + message: 'Are you sure you want to rewrite it?' + }) .then(answers => { if (answers.rewrite === false) { return process.exit(0) @@ -41,6 +37,7 @@ module.exports = function (path = '', local, theme) { createFile(cwdPath, local, theme) console.log(msg) }) + .catch(console.error) return false } diff --git a/package-lock.json b/package-lock.json index 468bd18..4695555 100644 --- a/package-lock.json +++ b/package-lock.json @@ -601,20 +601,10 @@ } } }, - "ansi-escapes": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.1.tgz", - "integrity": "sha512-JWF7ocqNrp8u9oqpgV+wH5ftbt+cfvv+PTjOvKLT3AdYly/LmORARfEVT1iyjwN+4MqE5UmVKoAdIBqeoCHgLA==", - "requires": { - "type-fest": "^0.11.0" - }, - "dependencies": { - "type-fest": { - "version": "0.11.0", - "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.11.0.tgz", - "integrity": "sha512-OdjXJxnCN1AvyLSzeKIgXTXxV+99ZuXl3Hpo9XpJAv9MBcHrrJOQ5kV7ypXOuQie+AmWG25hLbiKdwYTifzcfQ==" - } - } + "ansi-colors": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", + "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==" }, "ansi-regex": { "version": "2.1.1", @@ -1685,11 +1675,6 @@ "supports-color": "^5.3.0" } }, - "chardet": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/chardet/-/chardet-0.7.0.tgz", - "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==" - }, "chokidar": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.3.1.tgz", @@ -3427,6 +3412,14 @@ "once": "^1.4.0" } }, + "enquirer": { + "version": "2.3.6", + "resolved": "https://registry.npmjs.org/enquirer/-/enquirer-2.3.6.tgz", + "integrity": "sha512-yjNnPr315/FjS4zIsUxYguYUPP2e1NK4d7E7ZOLiyYCcbFBiTMyID+2wvm2w6+pZ/odMA7cRkjhsPbltwBOrLg==", + "requires": { + "ansi-colors": "^4.1.1" + } + }, "equal-length": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/equal-length/-/equal-length-1.0.1.tgz", @@ -3918,16 +3911,6 @@ } } }, - "external-editor": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz", - "integrity": "sha512-hMQ4CX1p1izmuLYyZqLMO/qGNw10wSv9QDCPfzXfyFrOaCSSoRfqE1Kf1s5an66J5JZC62NewG+mK49jOCtQew==", - "requires": { - "chardet": "^0.7.0", - "iconv-lite": "^0.4.24", - "tmp": "^0.0.33" - } - }, "fast-deep-equal": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", @@ -5129,161 +5112,6 @@ "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==" }, - "inquirer": { - "version": "7.3.3", - "resolved": "https://registry.npmjs.org/inquirer/-/inquirer-7.3.3.tgz", - "integrity": "sha512-JG3eIAj5V9CwcGvuOmoo6LB9kbAYT8HXffUl6memuszlwDC/qvFAJw49XJ5NROSFNPxp3iQg1GqkFhaY/CR0IA==", - "requires": { - "ansi-escapes": "^4.2.1", - "chalk": "^4.1.0", - "cli-cursor": "^3.1.0", - "cli-width": "^3.0.0", - "external-editor": "^3.0.3", - "figures": "^3.0.0", - "lodash": "^4.17.19", - "mute-stream": "0.0.8", - "run-async": "^2.4.0", - "rxjs": "^6.6.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0", - "through": "^2.3.6" - }, - "dependencies": { - "ansi-regex": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", - "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==" - }, - "ansi-styles": { - "version": "4.2.1", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", - "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", - "requires": { - "@types/color-name": "^1.1.1", - "color-convert": "^2.0.1" - } - }, - "chalk": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", - "integrity": "sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==", - "requires": { - "ansi-styles": "^4.1.0", - "supports-color": "^7.1.0" - } - }, - "cli-cursor": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-3.1.0.tgz", - "integrity": "sha512-I/zHAwsKf9FqGoXM4WWRACob9+SNukZTd94DWF57E4toouRulbCxcUh6RKUEOQlYTHJnzkPMySvPNaaSLNfLZw==", - "requires": { - "restore-cursor": "^3.1.0" - } - }, - "cli-width": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/cli-width/-/cli-width-3.0.0.tgz", - "integrity": "sha512-FxqpkPPwu1HjuN93Omfm4h8uIanXofW0RxVEW3k5RKx+mJJYSthzNhp32Kzxxy3YAEZ/Dc/EWN1vZRY0+kOhbw==" - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" - }, - "emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" - }, - "figures": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz", - "integrity": "sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg==", - "requires": { - "escape-string-regexp": "^1.0.5" - } - }, - "has-flag": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", - "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" - }, - "is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==" - }, - "mimic-fn": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", - "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==" - }, - "onetime": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", - "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", - "requires": { - "mimic-fn": "^2.1.0" - } - }, - "restore-cursor": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", - "integrity": "sha512-l+sSefzHpj5qimhFSE5a8nufZYAM3sBSVMAPtYkmC+4EH2anSGaEMXSD0izRQbu9nfyQ9y5JrVmp7E8oZrUjvA==", - "requires": { - "onetime": "^5.1.0", - "signal-exit": "^3.0.2" - } - }, - "run-async": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz", - "integrity": "sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ==" - }, - "rxjs": { - "version": "6.6.2", - "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.2.tgz", - "integrity": "sha512-BHdBMVoWC2sL26w//BCu3YzKT4s2jip/WhwsGEDmeKYBhKDZeYezVUnHatYB7L85v5xs0BAQmg6BEYJEKxBabg==", - "requires": { - "tslib": "^1.9.0" - } - }, - "string-width": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz", - "integrity": "sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==", - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.0" - } - }, - "strip-ansi": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", - "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", - "requires": { - "ansi-regex": "^5.0.0" - } - }, - "supports-color": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", - "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", - "requires": { - "has-flag": "^4.0.0" - } - } - } - }, "interpret": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/interpret/-/interpret-1.4.0.tgz", @@ -6015,7 +5843,8 @@ "lodash": { "version": "4.17.19", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.19.tgz", - "integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==" + "integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==", + "dev": true }, "lodash._reinterpolate": { "version": "3.0.0", @@ -6324,11 +6153,6 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, - "mute-stream": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", - "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==" - }, "natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", @@ -6548,7 +6372,8 @@ "os-tmpdir": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", - "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=" + "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=", + "dev": true }, "p-cancelable": { "version": "1.1.0", @@ -7954,7 +7779,8 @@ "through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", - "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=" + "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", + "dev": true }, "through2": { "version": "3.0.2", @@ -7987,6 +7813,7 @@ "version": "0.0.33", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", "integrity": "sha512-jRCJlojKnZ3addtTOjdIqoRuPEKBvNXcGYqzO6zWZX8KfKEpnGY5jfggJQ3EjKuu8D4bJRr0y+cYJFmYbImXGw==", + "dev": true, "requires": { "os-tmpdir": "~1.0.2" } @@ -8036,7 +7863,8 @@ "tslib": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", - "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==" + "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==", + "dev": true }, "tweezer.js": { "version": "1.5.0", diff --git a/package.json b/package.json index fa80df0..ded444f 100644 --- a/package.json +++ b/package.json @@ -54,9 +54,9 @@ "cp-file": "^7.0.0", "docsify": "^4.10.2", "docsify-server-renderer": ">=4", + "enquirer": "^2.3.6", "fs-extra": "^8.1.0", "get-port": "^5.0.0", - "inquirer": "^7.3.3", "livereload": "^0.9.1", "lru-cache": "^5.1.1", "open": "^6.4.0", From 7a6edc5cae4166739c8729ea4b4d8909c392bbba Mon Sep 17 00:00:00 2001 From: sy-records <52o@qq52o.cn> Date: Thu, 20 Aug 2020 14:55:26 +0800 Subject: [PATCH 9/9] update symbols --- e2e/index.js.md | 2 +- e2e/index.js.snap | Bin 817 -> 803 bytes lib/commands/init.js | 3 +++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/e2e/index.js.md b/e2e/index.js.md index 162a2ee..a06f032 100644 --- a/e2e/index.js.md +++ b/e2e/index.js.md @@ -17,7 +17,7 @@ Generated by [AVA](https://ava.li). > Snapshot 1 `./ already exists.␊ - [?25l[36m?[39m [1mAre you sure you want to rewrite it?[22m [2m(y/N)[22m [2m›[22m [36mfalse[39m[10D[2K[1G[32m✔[39m [1mAre you sure you want to rewrite it?[22m [2m(y/N)[22m [2m·[22m [32mfalse[39m[4D␊ + [?25l[36m?[39m [1mAre you sure you want to rewrite it?[22m [2m(y/N)[22m [36mfalse[39m[10D[2K[1G[32m✔[39m [1mAre you sure you want to rewrite it?[22m [2m(y/N)[22m [32mfalse[39m[4D␊ [?25h` ## rejects promise due to error on passing in an unknown command diff --git a/e2e/index.js.snap b/e2e/index.js.snap index eaff9de8d3c0da309e4f638a5a3dc0a987f234be..7693d2cf4594688da78a07f3e7266689026e76ed 100644 GIT binary patch literal 803 zcmV+;1Kj*URzV<BZeeh9Xm4~Nb}|YA0HseiSTki;D_+C%1XCpP&>xEk00000000B+ zlut+$Q5?r-G%@E8Rz!a!`B|3=cSbi0-279yArh$Ux}<DkZ)cvnqciiCd2e@Hi~dkS zw+JO73@Ys(-h#YXc!*A7r?Ti0=)Isz9t?UjJ8SMmQabK~H_UwJ`@X;ToA+TB1VPv; zT-_Oqt=RX<7H>~Hy+n@8h=Ma}`7E^$%zb&Yf6`|(&p+O~{9bg`UOp$kR^I<Se!eR6 zG5+)Irz>NktKKRRgudX+@2LwbHM6_lmDUW5MnqSAwM7u*rI%>#$MnRu%y@YA^@ls6 ztL`cn1iU=`B0N&s_vm}=RONW{4bfHmD+FQTX2r_Fi3j_-pTi!dyqDK;)G0o-@WJbM zN57?a%>H`z<lOu<(N!NxeAhy`+ksdnY!|B~ji^)~%=%PAhcvdSPON|g&>%O+_0nd& zCDkPnisCo`-V$iiEuCGa*iPdXXi6fMXpy8gVw%X(s1uSmIzEUxhJFBOvoT_rf`v1# zV~x?xT6Km}78pcDMozbZ5lGrNt@DLcXINglk|CRUn*a#s{DZ`Xa5yAM?FNbQn64z_ z?KuT~z63UswctyDGr|dy0Y`z2jA)Dy10$>74fH-9&rExPo&r|NjPc!UBv1+xHDzLp zA?6)Og0UnGD2mtc5S8OPOQd45PV(Bnxtx>c`8bUYl5|R}P50a?G5<!aU8uzPmsCtd z8Mc+SuFjrN$LUB<M`yciYDHLzuxt*No+2zoSk{3>lA>oqp{`Ir)B&>N?)E7p5v5p@ zp_?~GG0-Gdo%2GV=0GVxtg(n#5wUd<i&(=J$ylp^1z;#;4XcH}D)FS$!FkY;p^v!T z0Zpk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7 z-iDK~%Nn$3+FF}~buf^$2DRK&=0{jQN1GmD1<OcL0UN^VSO&-?opGkfrIDt<aicVH ztj25-_gWK5BUR=pn?Qyp#gOwJ(%9mT*EUJp!e-F9U<U#YJ76BpsBK5qUl&JStiA}< vK5Q`JDhuJtp!jlDJhTWzFek?UQ_a`U*GdL*N>&F~T8#e%eRBXTj0*q&9qNo0 diff --git a/lib/commands/init.js b/lib/commands/init.js index 5d76cb8..3d2c451 100644 --- a/lib/commands/init.js +++ b/lib/commands/init.js @@ -27,6 +27,9 @@ module.exports = function (path = '', local, theme) { prompt({ type: 'confirm', name: 'rewrite', + symbols: { + separator: '' + }, message: 'Are you sure you want to rewrite it?' }) .then(answers => {