Skip to content

Commit

Permalink
spec: add devDependencies tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
erisu committed Jan 28, 2025
1 parent f6fa980 commit 7086a7d
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
13 changes: 12 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"jasmine": "^5.1.0",
"jasmine-spec-reporter": "^7.0.0",
"nyc": "^15.1.0",
"rewire": "^7.0.0"
"rewire": "^7.0.0",
"tmp": "^0.2.3"
},
"engines": {
"node": ">=16.13.0"
Expand Down
14 changes: 11 additions & 3 deletions spec/unit/pluginHandlers/common.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,19 @@ const rewire = require('rewire');
const common = rewire('../../../lib/pluginHandlers');
const path = require('node:path');
const fs = require('node:fs');
const osenv = require('node:os');
const tmp = require('tmp');

const test_dir = path.join(osenv.tmpdir(), 'test_plugman');
tmp.setGracefulCleanup();

const tempdir = tmp.dirSync({ unsafeCleanup: true });
const test_dir = path.join(tempdir.name, 'test_plugman');
const project_dir = path.join(test_dir, 'project');
const src = path.join(project_dir, 'src');
const dest = path.join(project_dir, 'dest');
const java_dir = path.join(src, 'one', 'two', 'three');
const java_file = path.join(java_dir, 'test.java');
const symlink_file = path.join(java_dir, 'symlink');
const non_plugin_file = path.join(osenv.tmpdir(), 'non_plugin_file');
const non_plugin_file = path.join(tempdir.name, 'non_plugin_file');

const copyFile = common.__get__('copyFile');
const deleteJava = common.__get__('deleteJava');
Expand All @@ -42,6 +45,11 @@ function outputFileSync (file, content) {
}

describe('common platform handler', function () {
afterAll(() => {
// Remove tempdir after all specs complete
fs.rmSync(tempdir.name, { recursive: true, force: true });
});

afterEach(() => {
fs.rmSync(test_dir, { recursive: true, force: true });
fs.rmSync(non_plugin_file, { recursive: true, force: true });
Expand Down

0 comments on commit 7086a7d

Please sign in to comment.