Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
Sync with PIO IDE for VSCode
Browse files Browse the repository at this point in the history
  • Loading branch information
ivankravets committed Jun 3, 2017
1 parent 570712f commit 43f29a0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
9 changes: 8 additions & 1 deletion lib/installer/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* the root directory of this source tree.
*/

import * as utils from '../utils';

import { CompositeDisposable, Emitter } from 'atom';

import AtomDependenciesStage from './stages/atom-dependencies';
Expand All @@ -16,6 +18,7 @@ import ConfigurationStage from './stages/configuration';
import InstallerProgressModal from './progress-modal';
import PlatformIOCoreStage from './stages/platformio-core';
import ProjectExamplesStage from './stages/project-examples';
import semver from 'semver';


export default class InstallationManager {
Expand All @@ -29,7 +32,11 @@ export default class InstallationManager {
new CodeCompletionEngineStage(this.eventbus),
new AtomDependenciesStage(this.eventbus),
new ProjectExamplesStage(this.eventbus),
new PlatformIOCoreStage(this.eventbus)
new PlatformIOCoreStage(this.eventbus, {
useBuiltinPIOCore: atom.config.get('platformio-ide.useBuiltinPIOCore'),
setUseBuiltinPIOCore: (value) => atom.config.set('platformio-ide.useBuiltinPIOCore', value),
useDevelopmentPIOCore: atom.config.get('platformio-ide.advanced.useDevelopmentPIOCore') || semver.prerelease(utils.getIDEVersion())
})
];

this.progress = new InstallerProgressModal({
Expand Down
3 changes: 2 additions & 1 deletion lib/installer/stages/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ export default class BaseStage {

static STORAGE_STATE_KEY = 'platformio-ide:installer-state';

constructor(eventbus) {
constructor(eventbus, params = {}) {
this.eventbus = eventbus;
this.params = params;
this._status = BaseStage.STATUS_CHECKING;
}

Expand Down
10 changes: 5 additions & 5 deletions lib/installer/stages/platformio-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export default class PlatformIOCoreStage extends BaseStage {
async installPIOCore() {
let cmd = 'pip';
const args = ['install', '--no-cache-dir', '-U'];
if (atom.config.get('platformio-ide.advanced.useDevelopmentPIOCore') || semver.prerelease(utils.getIDEVersion())) {
if (this.params.useDevelopmentPIOCore) {
cmd = path.join(config.ENV_BIN_DIR, 'pip');
args.push('https://github.com/platformio/platformio/archive/develop.zip');
} else {
Expand Down Expand Up @@ -324,7 +324,7 @@ export default class PlatformIOCoreStage extends BaseStage {
}

async check() {
if (atom.config.get('platformio-ide.useBuiltinPIOCore')) {
if (this.params.useBuiltinPIOCore) {
if (!fs.isDirectorySync(config.ENV_BIN_DIR)) {
throw new Error('Virtual environment is not created');
}
Expand All @@ -335,8 +335,8 @@ export default class PlatformIOCoreStage extends BaseStage {

const coreVersion = await utils.getCoreVersion();
if (semver.lt(PEPverToSemver(coreVersion), config.PIO_CORE_MIN_VERSION)) {
atom.config.set('platformio-ide.useBuiltinPIOCore', true);
throw new Error('Incompatible PIO Core', coreVersion);
this.params.setUseBuiltinPIOCore(true);
throw new Error(`Incompatible PIO Core ${coreVersion}`);
}

this.status = BaseStage.STATUS_SUCCESSED;
Expand All @@ -348,7 +348,7 @@ export default class PlatformIOCoreStage extends BaseStage {
if (this.status === BaseStage.STATUS_SUCCESSED) {
return true;
}
if (!atom.config.get('platformio-ide.useBuiltinPIOCore')) {
if (!this.params.useBuiltinPIOCore) {
this.status = BaseStage.STATUS_SUCCESSED;
return true;
}
Expand Down

0 comments on commit 43f29a0

Please sign in to comment.