Skip to content

Commit

Permalink
修复错误
Browse files Browse the repository at this point in the history
  • Loading branch information
gucong3000 committed May 23, 2023
1 parent 2846d45 commit 9d18c6f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js → .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
env: {
browser: false,
commonjs: true,
commonjs: false,
es2021: true,
node: true,
},
Expand Down
4 changes: 2 additions & 2 deletions lib/sudo.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ function writeFileSync (file, data) {
}

async function writeFile (file, data) {
if (isElevated()) {
if (await isElevated()) {
return writeFileSync(file, data);
} else {
cache.fs[file] = data.toString();
}
}

async function spawn (...args) {
if (isElevated()) {
if (await isElevated()) {
return spawnAsync(...args);
} else {
cache.cmd.push(args);
Expand Down
2 changes: 1 addition & 1 deletion test/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ describe('根据命令行参数改变环境变量', () => {
assert.strictEqual(env.NODIST_NODE_MIRROR, 'https://my.mock/node');
} else {
assert.strictEqual(env.NVM_NODEJS_ORG_MIRROR, 'https://my.mock/node');
assert.strictEqual(env.N_NODE_MIRROR, 'https://my.mock/iojs');
assert.strictEqual(env.N_NODE_MIRROR, 'https://my.mock/node');
}
});
it('--disturl=https://nodejs.mock', async () => {
Expand Down
10 changes: 9 additions & 1 deletion test/install.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import spawn from '../lib/spawn.js';
import { fileURLToPath } from 'node:url';
import path from 'node:path';

describe('install', () => {
it('install script', async () => {
const filename = fileURLToPath(
import.meta.url,
);
await spawn([
process.execPath,
require.resolve('../lib/install'),
path.resolve(
path.dirname(filename),
'../lib/install',
),
], {
encoding: 'utf8',
env: {
Expand Down

0 comments on commit 9d18c6f

Please sign in to comment.