const { parse } = require('semver');
const { execute, publishPackagesToNpm } = require('./utils');

async function main() {
  const json = require('../../dist/package.json');
  let commit = process.env.TRAVIS_PULL_REQUEST_SHA;
  if (!commit) {
    const lastCommit = await execute('git rev-parse HEAD');
    commit = lastCommit.toString().trim();
  }

  // shorten commit
  commit = commit.slice(0, 7);

  await execute(`npm view ${json.name} version`).then( async ( version )=> {
    const newVersion = (version + '-develop-' + commit);
    console.log('publishing new version', newVersion);
    await publishPackagesToNpm(newVersion, 'dev');
  });

}

main();

@@ -91,16 +91,53 @@
 utils');
+%0Aconst %7B resolve %7D = require('path');
 %0A%0Aasync 
@@ -205,16 +205,71 @@
 json');%0A
+  const buildPath = resolve(__dirname, '../../dist/');%0A
   let co
@@ -565,13 +565,129 @@
 on )
+ 
 =%3E %7B%0A
+    console.log( buildPath);%0A    await execute(%60npm version $%7Bversion%7D%60, %7B cwd: buildPath %7D).then( async () =%3E %7B%0A  
     
@@ -739,16 +739,18 @@
 ommit);%0A
+  
     cons
@@ -796,16 +796,18 @@
 rsion);%0A
+  
     awai
@@ -849,16 +849,24 @@
 'dev');%0A
+    %7D);%0A
   %7D);%0A%0A%7D

fix ci npm ERR! code E404 npm ERR! 404 Not Found: 0.0.0-dev-develop-dc06503@latest #5