-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: work around npm6/postcss8 hoisting issue (#6358)
Closes #6342
- Loading branch information
1 parent
2035543
commit 27b4263
Showing
4 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const fs = require('fs') | ||
const path = require('path') | ||
|
||
const { semver } = require('@vue/cli-shared-utils') | ||
|
||
const cwd = process.cwd() | ||
|
||
const userAgent = process.env.npm_config_user_agent | ||
const usesNpm6 = userAgent && userAgent.startsWith('npm/6.') | ||
if (!usesNpm6) { | ||
process.exit() | ||
} | ||
|
||
const pkgPath = path.resolve(cwd, './package.json') | ||
const pkg = fs.existsSync(pkgPath) ? require(pkgPath) : {} | ||
const deps = { | ||
...pkg.dependencies, | ||
...pkg.devDependencies, | ||
...pkg.optionalDependencies | ||
} | ||
|
||
let hasPostCSS8 = false | ||
if (deps.postcss) { | ||
hasPostCSS8 = semver.intersects(deps.postcss, '8.x') | ||
} | ||
|
||
if (!hasPostCSS8) { | ||
const hotfixPath = path.resolve(__dirname, '../generator/hotfix-npm6only.js') | ||
const targetPath = path.resolve(__dirname, '../generator/hotfix.js') | ||
fs.renameSync(hotfixPath, targetPath) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// this file will be renamed to hotfix.js if the package is installed by npm 6 | ||
module.exports = (api) => { | ||
api.extendPackage({ | ||
dependencies: { | ||
postcss: '^8.2.6' | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters