diff --git a/.github/workflows/auto-npm-publish.yml b/.github/workflows/auto-npm-publish.yml new file mode 100644 index 0000000..718f4aa --- /dev/null +++ b/.github/workflows/auto-npm-publish.yml @@ -0,0 +1,23 @@ +name: auto-npm-publish +on: + push: + branches: + - master +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v1 + with: + node-version: 10 + - run: npm install + - run: npm test + - run: npm run build:prod + - name: NPM Publish + uses: JS-DevTools/npm-publish@v1 + with: + package: ./dist/ngx-mqtt/package.json + check-version: true + token: ${{ secrets.NPM_TOKEN }} + diff --git a/projects/ngx-mqtt/.no-postinstall b/projects/ngx-mqtt/.no-postinstall new file mode 100644 index 0000000..e69de29 diff --git a/projects/ngx-mqtt/postinstall.js b/projects/ngx-mqtt/postinstall.js index d93a106..fdc334c 100644 --- a/projects/ngx-mqtt/postinstall.js +++ b/projects/ngx-mqtt/postinstall.js @@ -3,6 +3,21 @@ if (process.env['mqtt-disable-hook']) { } const fs = require('fs'); + +// to check if it's development directory +// the .no-postinstall file is used +// it doesn't exist in built library +const noPostInstallPath = './.no-postinstall'; +try { + if (fs.existsSync(noPostInstallPath)) { + // don't run postinstall in the dev directory + return 0; + } +} catch(err) { + console.error(err); + return 1; +} + const f = '../../node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/browser.js'; fs.readFile(f, 'utf8', function (err,data) {