Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix module export #416

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

## Beta

## [15.0.0] 2024-26-08
## [15.0.1] 2024-08-26

- Fix module export
- Fix deploy in vscode script

## [15.0.0] 2024-08-26

- Convert to [ES Module](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules)
- Upgrade to CodeNarc 3.5.0
Expand Down
3 changes: 3 additions & 0 deletions index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { NpmGroovyLint } from "./lib/index.js";

export default NpmGroovyLint;
34 changes: 19 additions & 15 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,24 @@
import NpmGroovyLint from "./groovy-lint.js";
import { pathToFileURL } from "url";

// Create linter/formatter/fixer with arguments
const linter = new NpmGroovyLint(process.argv, { origin: "index" });
if (import.meta.url === pathToFileURL(process.argv[1]).href) {
// Create linter/formatter/fixer with arguments
const linter = new NpmGroovyLint(process.argv, { origin: "index" });

// Run asynchronously to use the returned status for process.exit
(async () => {
try {
await linter.run();
process.exitCode = linter.status;
} catch (err) {
console.error("Unexpected error: " + err.message + "\n" + err.stack);
process.exitCode = 2;
// Quit if called by CLI and not as a module
if (import.meta.url === pathToFileURL(process.argv[1]).href) {
process.exit();
// Run asynchronously to use the returned status for process.exit
(async () => {
try {
await linter.run();
process.exitCode = linter.status;
} catch (err) {
console.error("Unexpected error: " + err.message + "\n" + err.stack);
process.exitCode = 2;
// Quit if called by CLI and not as a module
if (import.meta.url === pathToFileURL(process.argv[1]).href) {
process.exit();
}
}
}
})();
})();
}

export { NpmGroovyLint };
12 changes: 6 additions & 6 deletions scripts/deploy-in-vscode.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


// Imports
import { existsSync, emptyDirSync, mkdirSync, copySync } from 'fs-extra';
import fs from 'fs-extra';

console.log('---- START DEPLOY IN VSCODE INSTALLED npm-groovy-lint PACKAGE ----');

Expand All @@ -15,16 +15,16 @@ const targetPath = `${vsCodeGroovyLintPath}/server/node_modules/npm-groovy-lint`
console.info(`GroovyLint: Starting copying package in vscode for testing`);

// Reset target folder
if (existsSync(targetPath)) {
emptyDirSync(targetPath);
if (fs.existsSync(targetPath)) {
fs.emptyDirSync(targetPath);
}
else {
mkdirSync(targetPath);
fs.mkdirSync(targetPath);
}

// Copy files into dest folder
for (const path of ['package.json', 'README.md', 'CHANGELOG.md', 'LICENSE', 'lib']) {
copySync(path, `${targetPath}/${path}`);
for (const path of ['index.mjs', 'package.json', 'README.md', 'CHANGELOG.md', 'LICENSE', 'lib']) {
fs.copySync(path, `${targetPath}/${path}`);
}

console.info(`GroovyLint: Copied files into ${targetPath}`);
Expand Down
Loading