Do not install typings for plugins installed with '--fetch' option

Note that we still need to install typings for plugins which don’t have typings available on NPM
This commit is contained in:
Vladimir Kotikov 2016-11-28 16:37:47 +03:00
Родитель c9c156db66
Коммит a6afb25adb
2 изменённых файлов: 24 добавлений и 3 удалений

Просмотреть файл

@ -57,10 +57,12 @@
"typingFile": "cordova/plugins/WebSQL.d.ts"
},
"cordova-plugin-x-toast": {
"typingFile": "cordova/plugins/Toast.d.ts"
"typingFile": "cordova/plugins/Toast.d.ts",
"forceInstallTypings": true
},
"ionic-plugin-keyboard": {
"typingFile": "cordova-ionic/plugins/keyboard.d.ts"
"typingFile": "cordova-ionic/plugins/keyboard.d.ts",
"forceInstallTypings": true
},
"phonegap-plugin-barcodescanner": {
"typingFile": "cordova/plugins/BarcodeScanner.d.ts"
@ -68,4 +70,4 @@
"phonegap-plugin-push": {
"typingFile": "cordova/plugins/Push.d.ts"
}
}
}

Просмотреть файл

@ -10,6 +10,7 @@ import {CordovaProjectHelper} from './utils/cordovaProjectHelper';
import {CordovaCommandHelper} from './utils/cordovaCommandHelper';
import {ExtensionServer} from './extension/extensionServer';
import * as Q from "q";
import * as semver from 'semver';
import {PluginSimulator} from "./extension/simulate";
import {Telemetry} from './utils/telemetry';
import {TelemetryHelper} from './utils/telemetryHelper';
@ -213,6 +214,24 @@ function getRelativeTypeDefinitionFilePath(projectRoot: string, parentPath: stri
function updatePluginTypeDefinitions(cordovaProjectRoot: string): void {
let installedPlugins: string[] = CordovaProjectHelper.getInstalledPlugins(cordovaProjectRoot);
const nodeModulesDir = path.resolve(cordovaProjectRoot, 'node_modules');
if (semver.gte(vscode.version, '1.7.2-insider') && fs.existsSync(nodeModulesDir)) {
// Read installed node modules and filter out plugins that have been already installed in node_modules
// This happens if user has used '--fetch' option to install plugin. In this case VSCode will provide
// own intellisense for these plugins using ATA (automatic typings acquisition)
try {
const installedNpmModules: string[] = fs.readdirSync(nodeModulesDir);
installedPlugins = installedPlugins
.filter(pluginId => {
// plugins with `forceInstallTypings` flag don't have typings on NPM yet,
// so we still need to install these even if they present in 'node_modules'
return getPluginTypingsJson()[pluginId].forceInstallTypings ||
installedNpmModules.indexOf(pluginId) === -1;
});
} catch (e) { }
}
let newTypeDefs = getNewTypeDefinitions(installedPlugins);
let cordovaPluginTypesFolder = CordovaProjectHelper.getCordovaPluginTypeDefsPath(cordovaProjectRoot);
let ionicPluginTypesFolder = CordovaProjectHelper.getIonicPluginTypeDefsPath(cordovaProjectRoot);