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

use fs-extra copy instead of ncp #318

Merged
merged 2 commits into from
Apr 12, 2016
Merged
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
2 changes: 1 addition & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ Object (also known as a "hash") of application metadata to embed into the execut

### `err`

*Error* (or *Array*, in the case of an `ncp` error)
*Error* (or *Array*, in the case of an `copy` error)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does copy actually create an Array on erroring? Because that would be very unfortunate.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I answered my own question below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can pass stopOnError: true to stop on first error.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably update all of the copy calls to use that (in a separate PR). Having err be potentially more than one type is problematic for users.


Contains errors, if any.

Expand Down
5 changes: 2 additions & 3 deletions mac.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
var common = require('./common')
var fs = require('fs-extra')
var ncp = require('ncp').ncp
var objectAssign = require('object-assign')
var path = require('path')
var plist = require('plist')
Expand Down Expand Up @@ -163,7 +162,7 @@ module.exports = {
// Ignore error if icon doesn't exist, in case it's only available for other OS
cb(null)
} else {
ncp(icon, path.join(contentsPath, 'Resources', appPlist.CFBundleIconFile), cb)
fs.copy(icon, path.join(contentsPath, 'Resources', appPlist.CFBundleIconFile), cb)
}
})
})
Expand All @@ -175,7 +174,7 @@ module.exports = {
if (!Array.isArray(extras)) extras = [extras]
extras.forEach(function (val) {
operations.push(function (cb) {
ncp(val, path.join(contentsPath, 'Resources', path.basename(val)), cb)
fs.copy(val, path.join(contentsPath, 'Resources', path.basename(val)), cb)
})
})
}
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"fs-extra": "^0.26.5",
"get-package-info": "0.0.2",
"minimist": "^1.1.1",
"ncp": "^2.0.0",
"object-assign": "^4.0.1",
"plist": "^1.1.0",
"rcedit": "^0.5.0",
Expand Down
5 changes: 2 additions & 3 deletions test/basic.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
var common = require('../common')
var config = require('./config.json')
var fs = require('fs-extra')
var ncp = require('ncp').ncp
var packager = require('..')
var path = require('path')
var series = require('run-series')
Expand Down Expand Up @@ -398,7 +397,7 @@ function createIgnoreOutDirTest (opts, distPath) {

series([
function (cb) {
ncp(path.join(__dirname, 'fixtures', 'basic'), appDir, {dereference: true, stopOnErr: true, filter: function (file) {
fs.copy(path.join(__dirname, 'fixtures', 'basic'), appDir, {dereference: true, stopOnErr: true, filter: function (file) {
return path.basename(file) !== 'node_modules'
}}, cb)
},
Expand Down Expand Up @@ -440,7 +439,7 @@ function createIgnoreImplicitOutDirTest (opts) {

series([
function (cb) {
ncp(path.join(__dirname, 'fixtures', 'basic'), appDir, {dereference: true, stopOnErr: true, filter: function (file) {
fs.copy(path.join(__dirname, 'fixtures', 'basic'), appDir, {dereference: true, stopOnErr: true, filter: function (file) {
return path.basename(file) !== 'node_modules'
}}, cb)
},
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"dependencies": {
"run-series": "^1.1.1"
},
"//": "ncp used to test https://github.com/electron-userland/electron-packager/pull/186",
"///": "(a module (with zero dependencies) that creates a file in node_modules/.bin)",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a really unfortunate way to annotate JSON files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but npm doesn't support other ways (e.g. typescript supports comments in the tsconfig.json) :(

"devDependencies": {
"ncp": "^2.0.0",
"run-waterfall": "^1.1.1",
Expand Down