diff --git a/build.sbt b/build.sbt index 27a8fe60e..35fc76bd4 100644 --- a/build.sbt +++ b/build.sbt @@ -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( @@ -264,6 +266,7 @@ lazy val buildNpmPackageTask = Def.task { Seq( licenseFile, readMeFile, - packageJsonFile + packageJsonFile, + warnFile, ) } diff --git a/js/package.json b/js/package.json index 599c10631..db38f1a72 100644 --- a/js/package.json +++ b/js/package.json @@ -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" diff --git a/js/warn-about-constructor-bc-break.js b/js/warn-about-constructor-bc-break.js new file mode 100644 index 000000000..df40ed111 --- /dev/null +++ b/js/warn-about-constructor-bc-break.js @@ -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(...)"' +);