diff --git a/lib/input.js b/lib/input.js
index 17f30e52..cd9753f9 100644
--- a/lib/input.js
+++ b/lib/input.js
@@ -21,23 +21,11 @@ const exec = __importStar(require("@actions/exec"));
const fs = __importStar(require("fs"));
const path = __importStar(require("path"));
const request = __importStar(require("request-promise-native"));
-/**
- * These environment variables are exposed for GitHub Actions.
- *
- * See https://bit.ly/2WlFUD7 for more information.
- */
-const { GITHUB_TOKEN, GITHUB_WORKSPACE } = process.env;
/**
* Parse our user input and set up our Vale environment.
*/
-function get(tmp) {
+function get(tmp, tok, dir) {
return __awaiter(this, void 0, void 0, function* () {
- // Add Vale, as copied in Docker, to the `$PATH` for later use:
- //
- // NOTE: This *should* be done already by the container `jdkato/vale`.
- core.addPath('/bin');
- const userToken = GITHUB_TOKEN;
- const workspace = GITHUB_WORKSPACE;
// Get the current version of Vale:
let version = '';
yield exec.exec('vale', ['-v'], {
@@ -46,19 +34,11 @@ function get(tmp) {
}
});
version = version.split(' ').slice(-1)[0];
- // Install our user-specified styles:
- const styles = core.getInput('styles').split('\n');
- for (const style of styles) {
- if (style !== '') {
- const name = style.split('/').slice(-1)[0].split('.zip')[0];
- core.info(`Installing style '${name}' ...`);
- yield exec.exec('vale', ['install', name, style], {
- cwd: workspace
- });
- }
- }
let args = ['--no-exit', '--output=JSON'];
- // Check if we were given an external config file:
+ // Check if we were given an external config file.
+ //
+ // NOTE: We need to do this first because we may not have a local config file
+ // to read the `StylesPath` from.
const config = core.getInput('config');
if (config !== '') {
core.info(`Downloading external config '${config}' ...`);
@@ -78,12 +58,25 @@ function get(tmp) {
}
});
}
+ // Install our user-specified styles:
+ const styles = core.getInput('styles').split('\n');
+ for (const style of styles) {
+ if (style !== '') {
+ const name = style.split('/').slice(-1)[0].split('.zip')[0];
+ core.info(`Installing style '${name}' ...`);
+ let cmd = ['install', name, style];
+ if (args.length > 2) {
+ cmd = args.concat(cmd);
+ }
+ yield exec.exec('vale', cmd, { cwd: dir });
+ }
+ }
// Figure out what we're supposed to lint:
const files = core.getInput('files');
if (files == 'all') {
args.push('.');
}
- else if (fs.existsSync(path.resolve(workspace, files))) {
+ else if (fs.existsSync(path.resolve(dir, files))) {
args.push(files);
}
else {
@@ -92,7 +85,7 @@ function get(tmp) {
}
core.info(`Vale set-up comeplete; using '${args}'.`);
return {
- token: userToken, workspace: workspace, args: args, version: version
+ token: tok, workspace: dir, args: args, version: version
};
});
}
diff --git a/lib/main.js b/lib/main.js
index d9747aa9..c9cb05dd 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -22,6 +22,12 @@ const tmp = __importStar(require("tmp"));
const execa = require("execa");
const check_1 = require("./check");
const input = __importStar(require("./input"));
+/**
+ * These environment variables are exposed for GitHub Actions.
+ *
+ * See https://bit.ly/2WlFUD7 for more information.
+ */
+const { GITHUB_TOKEN, GITHUB_WORKSPACE } = process.env;
function run(actionInput) {
return __awaiter(this, void 0, void 0, function* () {
const startedAt = new Date().toISOString();
@@ -43,12 +49,12 @@ exports.run = run;
function main() {
return __awaiter(this, void 0, void 0, function* () {
try {
- // TODO: core.info('::add-matcher::vale.json');
- const tmpobj = tmp.fileSync({ postfix: '.ini' });
- const actionInput = yield input.get(tmpobj);
+ const userToken = GITHUB_TOKEN;
+ const workspace = GITHUB_WORKSPACE;
+ const tmpobj = tmp.fileSync({ postfix: '.ini', dir: workspace });
+ const actionInput = yield input.get(tmpobj, userToken, workspace);
yield run(actionInput);
tmpobj.removeCallback();
- // TODO: core.info('::remove-matcher owner=vale::');
}
catch (error) {
core.setFailed(error.message);
diff --git a/package.json b/package.json
index ebee3dbb..0015f048 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "vale-action",
- "version": "1.0.0",
+ "version": "1.0.2",
"description": "The official GitHub Action for Vale -- install, manage, and run Vale with ease.",
"main": "lib/main.js",
"scripts": {
diff --git a/src/input.ts b/src/input.ts
index 5012806e..cf8a13c3 100644
--- a/src/input.ts
+++ b/src/input.ts
@@ -5,17 +5,6 @@ import * as fs from 'fs';
import * as path from 'path';
import * as request from 'request-promise-native';
-/**
- * These environment variables are exposed for GitHub Actions.
- *
- * See https://bit.ly/2WlFUD7 for more information.
- */
-const {
- GITHUB_TOKEN,
- GITHUB_WORKSPACE
-} = process.env;
-
-
/**
* Our expected input.
*
@@ -26,24 +15,13 @@ const {
* @args are Vale's run-time arguments.
*/
export interface Input {
- token: string,
- workspace: string,
- version: string,
- args: string[]
+ token: string, workspace: string, version: string, args: string[]
}
/**
* Parse our user input and set up our Vale environment.
*/
-export async function get(tmp: any): Promise {
- // Add Vale, as copied in Docker, to the `$PATH` for later use:
- //
- // NOTE: This *should* be done already by the container `jdkato/vale`.
- core.addPath('/bin');
-
- const userToken = GITHUB_TOKEN as string;
- const workspace = GITHUB_WORKSPACE as string;
-
+export async function get(tmp: any, tok: string, dir: string): Promise {
// Get the current version of Vale:
let version = '';
await exec.exec('vale', ['-v'], {
@@ -53,21 +31,11 @@ export async function get(tmp: any): Promise {
});
version = version.split(' ').slice(-1)[0];
- // Install our user-specified styles:
- const styles = core.getInput('styles').split('\n');
- for (const style of styles) {
- if (style !== '') {
- const name = style.split('/').slice(-1)[0].split('.zip')[0];
- core.info(`Installing style '${name}' ...`);
- await exec.exec('vale', ['install', name, style], {
- cwd: workspace
- });
- }
- }
-
let args: string[] = ['--no-exit', '--output=JSON'];
-
- // Check if we were given an external config file:
+ // Check if we were given an external config file.
+ //
+ // NOTE: We need to do this first because we may not have a local config file
+ // to read the `StylesPath` from.
const config = core.getInput('config');
if (config !== '') {
core.info(`Downloading external config '${config}' ...`);
@@ -87,20 +55,35 @@ export async function get(tmp: any): Promise {
});
}
+ // Install our user-specified styles:
+ const styles = core.getInput('styles').split('\n');
+ for (const style of styles) {
+ if (style !== '') {
+ const name = style.split('/').slice(-1)[0].split('.zip')[0];
+ core.info(`Installing style '${name}' ...`);
+
+ let cmd = ['install', name, style];
+ if (args.length > 2) {
+ cmd = args.concat(cmd);
+ }
+ await exec.exec('vale', cmd, {cwd: dir});
+ }
+ }
+
// Figure out what we're supposed to lint:
const files = core.getInput('files');
if (files == 'all') {
args.push('.');
- } else if (fs.existsSync(path.resolve(workspace, files))) {
- args.push(files)
+ } else if (fs.existsSync(path.resolve(dir, files))) {
+ args.push(files)
} else {
core.warning(
- `User-specified path (${files}) doesn't exist; falling back to 'all'.`)
+ `User-specified path (${files}) doesn't exist; falling back to 'all'.`)
args.push('.');
}
core.info(`Vale set-up comeplete; using '${args}'.`);
return {
- token: userToken, workspace: workspace, args: args, version: version
+ token: tok, workspace: dir, args: args, version: version
}
}
diff --git a/src/main.ts b/src/main.ts
index f78e4b2a..75e19114 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -7,6 +7,13 @@ import execa = require('execa');
import {CheckRunner} from './check';
import * as input from './input';
+/**
+ * These environment variables are exposed for GitHub Actions.
+ *
+ * See https://bit.ly/2WlFUD7 for more information.
+ */
+const {GITHUB_TOKEN, GITHUB_WORKSPACE} = process.env;
+
export async function run(actionInput: input.Input): Promise {
const startedAt = new Date().toISOString();
const alertResp = await execa('vale', actionInput.args);
@@ -27,15 +34,15 @@ export async function run(actionInput: input.Input): Promise {
async function main(): Promise {
try {
- // TODO: core.info('::add-matcher::vale.json');
+ const userToken = GITHUB_TOKEN as string;
+ const workspace = GITHUB_WORKSPACE as string;
- const tmpobj = tmp.fileSync({postfix: '.ini'});
- const actionInput = await input.get(tmpobj);
+ const tmpobj = tmp.fileSync({postfix: '.ini', dir: workspace});
+ const actionInput = await input.get(tmpobj, userToken, workspace);
await run(actionInput);
tmpobj.removeCallback();
- // TODO: core.info('::remove-matcher owner=vale::');
} catch (error) {
core.setFailed(error.message);
}