import {writeFile} from "fs-promise";

// write version to the package.json
export default async function(version, {
	package: pkg,
	packageFile: pkgfile
}) {
	pkg.version = version;
	await writeFile(pkgfile, JSON.stringify(pkg, null, 2));
}

@@ -30,16 +30,45 @@
 romise%22;
+%0Aimport SemVer from %22semver%22;
 %0A%0A// wri
@@ -139,16 +139,22 @@
 sion, %7B%0A
+%09tag,%0A
 %09package
@@ -187,16 +187,221 @@
 le%0A%7D) %7B%0A
+%09version = new SemVer(version);%0A%0A%09// set the correct dist tag%0A%09if (tag %7C%7C version.prerelease.length) %7B%0A%09%09if (pkg.publishConfig == null) pkg.publishConfig = %7B%7D;%0A%09%09pkg.publishConfig.tag = tag %7C%7C %22edge%22;%0A%09%7D%0A%0A
 %09pkg.ver
@@ -414,16 +414,27 @@
  version
+.toString()
 ;%0A%09await

add npm dist tag support