-
Notifications
You must be signed in to change notification settings - Fork 329
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9e73471
commit fdf68f2
Showing
7 changed files
with
168 additions
and
22 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,11 +24,11 @@ describe('deno', async function () { | |
'ncu-test-v2': 'npm:[email protected]', | ||
}, | ||
} | ||
await fs.writeFile(pkgFile, JSON.stringify(pkg), 'utf-8') | ||
await fs.writeFile(pkgFile, JSON.stringify(pkg)) | ||
try { | ||
const pkgData = await spawn( | ||
'node', | ||
[bin, '--jsonUpgraded', '--verbose', '--packageManager', 'deno', '--packageFile', pkgFile], | ||
[bin, '--jsonUpgraded', '--packageManager', 'deno', '--packageFile', pkgFile], | ||
undefined, | ||
) | ||
const pkg = jph.parse(pkgData) | ||
|
@@ -46,9 +46,9 @@ describe('deno', async function () { | |
'ncu-test-v2': 'npm:[email protected]', | ||
}, | ||
} | ||
await fs.writeFile(pkgFile, JSON.stringify(pkg), 'utf-8') | ||
await fs.writeFile(pkgFile, JSON.stringify(pkg)) | ||
try { | ||
const pkgData = await spawn('node', [bin, '--jsonUpgraded', '--verbose'], undefined, { | ||
const pkgData = await spawn('node', [bin, '--jsonUpgraded'], undefined, { | ||
cwd: tempDir, | ||
}) | ||
const pkg = jph.parse(pkgData) | ||
|
@@ -57,4 +57,71 @@ describe('deno', async function () { | |
await fs.rm(tempDir, { recursive: true, force: true }) | ||
} | ||
}) | ||
|
||
it('rewrite deno.json', async () => { | ||
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), 'npm-check-updates-')) | ||
const pkgFile = path.join(tempDir, 'deno.json') | ||
const pkg = { | ||
imports: { | ||
'ncu-test-v2': 'npm:[email protected]', | ||
}, | ||
} | ||
await fs.writeFile(pkgFile, JSON.stringify(pkg)) | ||
try { | ||
await spawn('node', [bin, '-u'], undefined, { cwd: tempDir }) | ||
const pkgDataNew = await fs.readFile(pkgFile, 'utf-8') | ||
const pkg = jph.parse(pkgDataNew) | ||
pkg.should.deep.equal({ | ||
imports: { | ||
'ncu-test-v2': 'npm:[email protected]', | ||
}, | ||
}) | ||
} finally { | ||
await fs.rm(tempDir, { recursive: true, force: true }) | ||
} | ||
}) | ||
|
||
it('auto detect deno.jsonc', async () => { | ||
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), 'npm-check-updates-')) | ||
const pkgFile = path.join(tempDir, 'deno.jsonc') | ||
const pkgString = `{ | ||
"imports": { | ||
// this comment should be ignored in a jsonc file | ||
"ncu-test-v2": "npm:[email protected]" | ||
} | ||
}` | ||
await fs.writeFile(pkgFile, pkgString) | ||
try { | ||
const pkgData = await spawn('node', [bin, '--jsonUpgraded'], undefined, { | ||
cwd: tempDir, | ||
}) | ||
const pkg = jph.parse(pkgData) | ||
pkg.should.have.property('ncu-test-v2') | ||
} finally { | ||
await fs.rm(tempDir, { recursive: true, force: true }) | ||
} | ||
}) | ||
|
||
it('rewrite deno.jsonc', async () => { | ||
const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), 'npm-check-updates-')) | ||
const pkgFile = path.join(tempDir, 'deno.jsonc') | ||
const pkg = { | ||
imports: { | ||
'ncu-test-v2': 'npm:[email protected]', | ||
}, | ||
} | ||
await fs.writeFile(pkgFile, JSON.stringify(pkg)) | ||
try { | ||
await spawn('node', [bin, '-u'], undefined, { cwd: tempDir }) | ||
const pkgDataNew = await fs.readFile(pkgFile, 'utf-8') | ||
const pkg = jph.parse(pkgDataNew) | ||
pkg.should.deep.equal({ | ||
imports: { | ||
'ncu-test-v2': 'npm:[email protected]', | ||
}, | ||
}) | ||
} finally { | ||
await fs.rm(tempDir, { recursive: true, force: true }) | ||
} | ||
}) | ||
}) |