Do not prompt setting enableProposedApi if set. Fix #5
This commit is contained in:
Родитель
a7e3e90f7e
Коммит
52f811c9eb
|
@ -1,5 +1,7 @@
|
|||
{
|
||||
"printWidth": 120,
|
||||
"semi": false,
|
||||
"singleQuote": true
|
||||
"singleQuote": true,
|
||||
"trailingComma": "none",
|
||||
"arrowParens": "avoid"
|
||||
}
|
18
index.js
18
index.js
|
@ -28,10 +28,22 @@ function handleDev(gitTagOrBranch) {
|
|||
var outPath = path_1["default"].resolve(process.cwd(), './vscode.proposed.d.ts');
|
||||
console.log("Downloading vscode.proposed.d.ts\nTo: " + outPath + "\nFrom: " + url);
|
||||
download(url, outPath).then(function () {
|
||||
console.log("Please set " + toRedString("\"enableProposedApi\": true") + " in package.json.");
|
||||
if (!isProposedApiEnabled()) {
|
||||
console.log("Please set " + toRedString("\"enableProposedApi\": true") + " in package.json.");
|
||||
}
|
||||
console.log('Read more about proposed API at: https://code.visualstudio.com/api/advanced-topics/using-proposed-api');
|
||||
});
|
||||
}
|
||||
function isProposedApiEnabled() {
|
||||
try {
|
||||
var packageJsonPath = path_1["default"].resolve(process.cwd(), './package.json');
|
||||
var packageJson = JSON.parse(fs_1["default"].readFileSync(packageJsonPath, 'utf-8'));
|
||||
return !!packageJson.enableProposedApi;
|
||||
}
|
||||
catch (_a) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
function handleDefaultDownload(gitTagOrBranch, force) {
|
||||
// handle master->main rename for old consumers
|
||||
if (gitTagOrBranch === 'master') {
|
||||
|
@ -57,10 +69,10 @@ function getHelpMessage() {
|
|||
' - npx vscode-dts dev Download vscode.proposed.d.ts',
|
||||
' - npx vscode-dts dev <git-tag | git-branch> Download vscode.proposed.d.ts from git tag/branch of microsoft/vscode',
|
||||
' - npx vscode-dts <git-tag | git-branch> Download vscode.d.ts from git tag/branch of microsoft/vscode',
|
||||
' - npx vscode-dts <git-tag | git-branch> -f Download vscode.d.ts and remove comflicing types in node_modules/@types/vscode',
|
||||
' - npx vscode-dts <git-tag | git-branch> -f Download vscode.d.ts and remove conflicting types in node_modules/@types/vscode',
|
||||
' - npx vscode-dts Print Help',
|
||||
' - npx vscode-dts -h Print Help',
|
||||
' - npx vscode-dts --help Print Help'
|
||||
' - npx vscode-dts --help Print Help',
|
||||
].join(os_1["default"].EOL);
|
||||
}
|
||||
function download(url, outPath) {
|
||||
|
|
16
index.ts
16
index.ts
|
@ -26,15 +26,27 @@ function handleDev(gitTagOrBranch?: string) {
|
|||
console.log(`Downloading vscode.proposed.d.ts\nTo: ${outPath}\nFrom: ${url}`)
|
||||
|
||||
download(url, outPath).then(() => {
|
||||
console.log(`Please set ${toRedString(`"enableProposedApi": true`)} in package.json.`)
|
||||
if (!isProposedApiEnabled()) {
|
||||
console.log(`Please set ${toRedString(`"enableProposedApi": true`)} in package.json.`)
|
||||
}
|
||||
console.log('Read more about proposed API at: https://code.visualstudio.com/api/advanced-topics/using-proposed-api')
|
||||
})
|
||||
}
|
||||
|
||||
function isProposedApiEnabled() {
|
||||
try {
|
||||
const packageJsonPath = path.resolve(process.cwd(), './package.json')
|
||||
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'))
|
||||
return !!packageJson.enableProposedApi
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
function handleDefaultDownload(gitTagOrBranch: string, force?: boolean) {
|
||||
// handle master->main rename for old consumers
|
||||
if (gitTagOrBranch === 'master') {
|
||||
gitTagOrBranch = 'main';
|
||||
gitTagOrBranch = 'main'
|
||||
}
|
||||
|
||||
const url = `https://raw.githubusercontent.com/microsoft/vscode/${gitTagOrBranch}/src/vs/vscode.d.ts`
|
||||
|
|
Загрузка…
Ссылка в новой задаче