From 753e021941ab707d740c30e02c2e148716bc9896 Mon Sep 17 00:00:00 2001 From: Evert Prants Date: Mon, 7 Dec 2020 20:48:15 +0200 Subject: [PATCH] handle scoped packages --- package-lock.json | 3 ++- package.json | 2 +- src/npm/executor.ts | 11 ++++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 90cf41e..036dd6c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -63,7 +63,8 @@ "@types/semver": { "version": "7.3.4", "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.3.4.tgz", - "integrity": "sha512-+nVsLKlcUCeMzD2ufHEYuJ9a2ovstb6Dp52A5VsoKxDXgvE051XgHI/33I1EymwkRGQkwnA0LkhnUzituGs4EQ==" + "integrity": "sha512-+nVsLKlcUCeMzD2ufHEYuJ9a2ovstb6Dp52A5VsoKxDXgvE051XgHI/33I1EymwkRGQkwnA0LkhnUzituGs4EQ==", + "dev": true }, "@types/tar": { "version": "4.0.4", diff --git a/package.json b/package.json index f8ea1dc..43b5961 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@squeebot/core", - "version": "3.0.0", + "version": "3.0.1", "description": "Squeebot v3 core for the execution environment", "main": "lib/index.js", "module": "lib/", diff --git a/src/npm/executor.ts b/src/npm/executor.ts index 12e5785..2f07e1c 100644 --- a/src/npm/executor.ts +++ b/src/npm/executor.ts @@ -1,7 +1,7 @@ import * as fs from 'fs-extra'; import * as path from 'path'; import { IEnvironment } from '../types/environment'; -import { IProcessData, spawnProcess } from '../util/run'; +import { spawnProcess } from '../util/run'; export class NPMExecutor { private installed: string[] = []; @@ -41,8 +41,13 @@ export class NPMExecutor { await this.init(); } - const pkgNoVersion = pkg.split('@')[0]; - if (this.installed.indexOf(pkgNoVersion) !== -1) { + let spi = 0; + if (pkg.indexOf('@') === 0) { + spi = 1; + } + + const pkgNoVersion = pkg.split('@')[spi]; + if (this.installed.indexOf((spi === 1 ? '@' : '') + pkgNoVersion) !== -1) { return; }