-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update pkg.files that if file exists (#37)
Avoid missing files when publish to npm
- Loading branch information
Showing
16 changed files
with
94 additions
and
7 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
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict'; | ||
|
||
const Command = require('./command'); | ||
|
||
class PkgfilesCommand extends Command { | ||
* run(cwd) { | ||
const args = [ | ||
'--entry', 'app', | ||
'--entry', 'config', | ||
'--entry', '*.js', | ||
]; | ||
const pkgfiles = require.resolve('ypkgfiles/bin/pkgfiles.js'); | ||
yield this.helper.forkNode(pkgfiles, args, { cwd }); | ||
} | ||
|
||
help() { | ||
return 'Generate pkg.files automatically'; | ||
} | ||
} | ||
|
||
module.exports = PkgfilesCommand; |
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use strict'; | ||
|
||
const path = require('path'); | ||
const assert = require('assert'); | ||
const coffee = require('coffee'); | ||
const fs = require('mz/fs'); | ||
|
||
describe('egg-bin pkgfiles', () => { | ||
const eggBin = require.resolve('../bin/egg-bin.js'); | ||
|
||
let cwd; | ||
afterEach(() => fs.writeFile(path.join(cwd, 'package.json'), '{}')); | ||
|
||
it('should update pkg.files', function* () { | ||
cwd = path.join(__dirname, 'fixtures/pkgfiles'); | ||
yield fs.writeFile(path.join(cwd, 'package.json'), '{}'); | ||
|
||
yield coffee.fork(eggBin, [ 'pkgfiles' ], { cwd }) | ||
// .debug() | ||
.expect('code', 0) | ||
.end(); | ||
|
||
const body = yield fs.readFile(path.join(cwd, 'package.json'), 'utf8'); | ||
assert.deepEqual(JSON.parse(body).files, [ | ||
'app', | ||
'config', | ||
'app.js', | ||
]); | ||
}); | ||
|
||
}); |
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 |
---|---|---|
|
@@ -27,5 +27,6 @@ | |
"dependencies": { | ||
"react": "^0.14.7", | ||
"react-dom": "^0.14.7" | ||
} | ||
} | ||
}, | ||
"files": [] | ||
} |
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 @@ | ||
'use strict'; | ||
|
||
module.exports = () => {}; |
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 @@ | ||
'use strict'; | ||
|
||
module.exports = {}; |
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 @@ | ||
'use strict'; | ||
|
||
module.exports = {}; |
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 @@ | ||
{} |
Empty file.
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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
{ | ||
"name": "test-files" | ||
} | ||
"name": "test-files", | ||
"files": [ | ||
"lib" | ||
] | ||
} |