Skip to content

Commit

Permalink
improv: throw error if using node <12 and the path to .pnp.js include…
Browse files Browse the repository at this point in the history
…s spaces (yarnpkg#716)
  • Loading branch information
ngryman committed Jan 28, 2020
1 parent a486cb5 commit 49241b1
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 25 deletions.
72 changes: 48 additions & 24 deletions .pnp.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion packages/plugin-pnp/package.json
Expand Up @@ -7,7 +7,8 @@
"@yarnpkg/plugin-stage": "workspace:^2.0.0-rc.15",
"@yarnpkg/pnp": "workspace:^2.0.0-rc.16",
"clipanion": "^2.1.5",
"micromatch": "^4.0.2"
"micromatch": "^4.0.2",
"semver": "^5.6.0"
},
"peerDependencies": {
"@yarnpkg/cli": "^2.0.0-rc.27",
Expand Down
5 changes: 5 additions & 0 deletions packages/plugin-pnp/sources/index.ts
Expand Up @@ -2,6 +2,8 @@ import {Hooks as CoreHooks, Plugin, Project, SettingsType} from '@yarnpkg/core';
import {Filename, PortablePath, npath, ppath, xfs} from '@yarnpkg/fslib';
import {Hooks as StageHooks} from '@yarnpkg/plugin-stage';

import semver from 'semver';

import {PnpLinker} from './PnpLinker';
import unplug from './commands/unplug';

Expand Down Expand Up @@ -31,6 +33,9 @@ async function setupScriptEnvironment(project: Project, env: {[key: string]: str
const pnpPath: PortablePath = getPnpPath(project).main;
const pnpRequire = `--require ${quotePathIfNeeded(npath.fromPortablePath(pnpPath))}`;

if (pnpPath.includes(' ') && semver.lt(process.versions.node, '12.0.0'))
throw new Error(`Expected the build location to not include spaces when using Node < 12.0.0 (${process.versions.node})`);

if (xfs.existsSync(pnpPath)) {
let nodeOptions = env.NODE_OPTIONS || ``;

Expand Down
1 change: 1 addition & 0 deletions yarn.lock
Expand Up @@ -5335,6 +5335,7 @@ __metadata:
"@yarnpkg/pnp": "workspace:^2.0.0-rc.16"
clipanion: ^2.1.5
micromatch: ^4.0.2
semver: ^5.6.0
peerDependencies:
"@yarnpkg/cli": ^2.0.0-rc.27
"@yarnpkg/core": ^2.0.0-rc.21
Expand Down

0 comments on commit 49241b1

Please sign in to comment.