Skip to content

Commit

Permalink
Execute run when module loads
Browse files Browse the repository at this point in the history
  • Loading branch information
saionaro committed Mar 5, 2020
1 parent d8ba0a4 commit eb9408e
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 51 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:

- name: Extract version
id: extract_version
uses: Saionaro/[email protected].4
uses: Saionaro/[email protected].5
# From now you can access version
- name: Print version
run: echo ${{ steps.extract_version.outputs.version }}
Expand Down
62 changes: 37 additions & 25 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,39 @@ module.exports =

module.exports = require("os");

/***/ }),

/***/ 311:
/***/ (function(module, __unusedexports, __webpack_require__) {

const core = __webpack_require__(470);
const path = __webpack_require__(622);

const workspace = process.env.GITHUB_WORKSPACE;

async function run() {
try {
const packagePath = path.join(workspace, "package.json");

core.debug(packagePath);

const pkg = require(packagePath);

core.debug(pkg);

const version = pkg.version.toString();

core.debug(version);

core.setOutput("version", version);
} catch (error) {
core.setFailed(error.message);
}
}

module.exports = run;


/***/ }),

/***/ 431:
Expand Down Expand Up @@ -359,35 +392,14 @@ module.exports = require("path");
/***/ }),

/***/ 676:
/***/ (function(module, __unusedexports, __webpack_require__) {

const core = __webpack_require__(470);
const path = __webpack_require__(622);

const workspace = process.env.GITHUB_WORKSPACE;

async function run() {
try {
const packagePath = path.join(workspace, "package.json");

core.debug(packagePath);

const pkg = require(packagePath);

core.debug(pkg);

const version = pkg.version.toString();
/***/ (function(__unusedmodule, __unusedexports, __webpack_require__) {

core.debug(version);
const run = __webpack_require__(311);

core.setOutput("version", version);
} catch (error) {
core.setFailed(error.message);
}
if (require.main === require.cache[eval('__filename')]) {
run();
}

module.exports = run;


/***/ })

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "extract-package-version",
"version": "1.0.4",
"version": "1.0.5",
"description": "Allows you to get the npm version of the package in your Github Actions workflow",
"main": "index.js",
"scripts": {
Expand Down
26 changes: 26 additions & 0 deletions src/extract-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const core = require("@actions/core");
const path = require("path");

const workspace = process.env.GITHUB_WORKSPACE;

async function run() {
try {
const packagePath = path.join(workspace, "package.json");

core.debug(packagePath);

const pkg = require(packagePath);

core.debug(pkg);

const version = pkg.version.toString();

core.debug(version);

core.setOutput("version", version);
} catch (error) {
core.setFailed(error.message);
}
}

module.exports = run;
27 changes: 3 additions & 24 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,5 @@
const core = require("@actions/core");
const path = require("path");
const run = require("./extract-version");

const workspace = process.env.GITHUB_WORKSPACE;

async function run() {
try {
const packagePath = path.join(workspace, "package.json");

core.debug(packagePath);

const pkg = require(packagePath);

core.debug(pkg);

const version = pkg.version.toString();

core.debug(version);

core.setOutput("version", version);
} catch (error) {
core.setFailed(error.message);
}
if (require.main === module) {
run();
}

module.exports = run;

0 comments on commit eb9408e

Please sign in to comment.