This repository has been archived by the owner on Jan 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: allow copyFile and copyFileSync from snapshot (#1484)
Co-authored-by: Nikolai Kolodziej <7687617+kldzj@users.noreply.github.com> Co-authored-by: Jesse Chan <jc@linux.com>
- Loading branch information
1 parent
37cc27e
commit 72bc8b3
Showing
6 changed files
with
153 additions
and
13 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
output | ||
sync.json | ||
async.json |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env node | ||
|
||
'use strict'; | ||
|
||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
const testPath = path.resolve(__dirname, 'input/test.json'); | ||
console.log(fs.readFileSync(testPath, 'utf8')); | ||
|
||
const syncPath = path.resolve(process.cwd(), 'output/sync.json'); | ||
fs.copyFileSync(testPath, syncPath); | ||
console.log(fs.readFileSync(syncPath, 'utf8')); | ||
|
||
const asyncPath = path.resolve(process.cwd(), 'output/async.json'); | ||
fs.copyFile(testPath, asyncPath, (err) => { | ||
if (err) throw err; | ||
console.log(fs.readFileSync(asyncPath, 'utf8')); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"key": "value" | ||
} |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env node | ||
|
||
'use strict'; | ||
|
||
const path = require('path'); | ||
const assert = require('assert'); | ||
const utils = require('../utils.js'); | ||
|
||
assert(!module.parent); | ||
assert(__dirname === process.cwd()); | ||
|
||
const target = process.argv[2] || 'host'; | ||
const input = './copy.js'; | ||
const output = './output/test-output.exe'; | ||
|
||
utils.mkdirp.sync(path.dirname(output)); | ||
utils.pkg.sync(['--target', target, '--output', output, '.']); | ||
|
||
let left, right; | ||
left = utils.spawn.sync('node', [path.basename(input)], { | ||
cwd: path.dirname(input), | ||
}); | ||
|
||
right = utils.spawn.sync(output, [], { | ||
cwd: path.dirname(input), | ||
}); | ||
|
||
assert.strictEqual(left, right); | ||
utils.vacuum.sync(path.dirname(output)); | ||
utils.vacuum.sync(path.join(__dirname, '/*sync.json')); |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"bin": "copy.js", | ||
"pkg": { | ||
"assets": [ | ||
"input/**/*" | ||
] | ||
} | ||
} |