Skip to content

Commit

Permalink
Add automatic notification about js API change on install
Browse files Browse the repository at this point in the history
  • Loading branch information
Mingun authored and generalmimon committed Oct 21, 2023
1 parent 81aeb77 commit 1be1580
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,11 @@ lazy val buildNpmPackageTask = Def.task {
val licenseFile = new File("js/npm/LICENSE")
val readMeFile = new File("js/npm/README.md")
val packageJsonFile = new File("js/npm/package.json")
val warnFile = new File("js/npm/warn-about-constructor-bc-break.js")

Files.copy(new File("LICENSE").toPath, licenseFile.toPath)
Files.copy(new File("js/README.md").toPath, readMeFile.toPath)
Files.copy(new File("js/warn-about-constructor-bc-break.js").toPath, warnFile.toPath)

val packageJsonTmpl = IO.read(new File("js/package.json"), UTF8)
val packageJsonContents = packageJsonTmpl.replaceFirst(
Expand All @@ -264,6 +266,7 @@ lazy val buildNpmPackageTask = Def.task {
Seq(
licenseFile,
readMeFile,
packageJsonFile
packageJsonFile,
warnFile,
)
}
1 change: 1 addition & 0 deletions js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"url": "git+https://github.com/kaitai-io/kaitai_struct_compiler.git"
},
"scripts": {
"postinstall": "node warn-about-constructor-bc-break.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"version": "OVERRIDDEN BY /build.sbt"
Expand Down
5 changes: 5 additions & 0 deletions js/warn-about-constructor-bc-break.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
console.warn(
'kaitai-struct-compiler: WARNING - you\'ve just installed the 0.11.0+ version. \
If you\'re coming from an older version, make sure to update your code - \
the usage changed from "(new KaitaiStructCompiler()).compile(...)" to "KaitaiStructCompiler.compile(...)"'
);

0 comments on commit 1be1580

Please sign in to comment.