forked from pnp/pnpjs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add post install script to test if SPFx version 1.12 - 1.14
Show's message that updates are needed & instructions are in the getting started guide
- Loading branch information
1 parent
b5c06c6
commit 9946ef4
Showing
2 changed files
with
22 additions
and
2 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
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,19 @@ | ||
const fs = require("fs"); | ||
const projectRoot = process.env.INIT_CWD; | ||
const packageLoc = `${projectRoot}\\package.json`; | ||
const packageFile = fs.readFileSync(packageLoc, "utf8"); | ||
const packageJSON = JSON.parse(packageFile); | ||
if (packageJSON.dependencies != null) { | ||
const spfxVersion = packageJSON.dependencies["@microsoft/sp-core-library"]; | ||
if (spfxVersion != null) { | ||
const spfxVersionFloat = parseFloat(spfxVersion); | ||
if (spfxVersionFloat > 1.11 && spfxVersionFloat < 1.15) { | ||
console.log(""); | ||
console.log("\x1b[43m%s\x1b[0m", " PnPjs WARNING "); | ||
console.log("\x1b[33m%s\x1b[0m", " The version of SPFx you are using requires an update to work with PnPjs. Please make sure to follow the getting started instructions to make the appropriate changes. ➡ https://pnp.github.io/pnpjs/getting-started/#spfx-version-1121-later"); | ||
console.log(""); | ||
} | ||
} | ||
} else { | ||
console.log("Package has no dependencies"); | ||
} |