@ckeditor/ckeditor5-dev-utils
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -11,2 +11,3 @@ /** | ||
const del = require( 'del' ); | ||
const fs = require( 'fs-extra' ); | ||
@@ -164,3 +165,3 @@ module.exports = { | ||
* @param {String} modulePath Path to NPM module. | ||
*/ | ||
*/ | ||
readPackageName( modulePath ) { | ||
@@ -255,2 +256,27 @@ const fs = require( 'fs' ); | ||
/** | ||
* Copies a file. Takes care of creating parent directory if it doesn't exist. | ||
* | ||
* @param {String} from Source path. | ||
* @param {String} to Destination path (directory with file name). | ||
* @returns {Promise} | ||
*/ | ||
copyFile( from, to ) { | ||
return new Promise( ( resolve, reject ) => { | ||
fs.readFile( from, 'utf8', ( err, data ) => { | ||
if ( err ) { | ||
return reject( err ); | ||
} | ||
fs.outputFile( to, data, ( err ) => { | ||
if ( err ) { | ||
return reject( err ); | ||
} | ||
return resolve(); | ||
} ); | ||
} ); | ||
} ); | ||
}, | ||
/** | ||
* Executes 'npm view' command for provided module name and returns Git url if one is found. Returns null if | ||
@@ -261,3 +287,3 @@ * module cannot be found. | ||
* @returns {*} | ||
*/ | ||
*/ | ||
getGitUrlFromNpm( name ) { | ||
@@ -264,0 +290,0 @@ try { |
{ | ||
"name": "@ckeditor/ckeditor5-dev-utils", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Utils for CKEditor 5 dev code (such as Gulp tasks).", | ||
@@ -10,11 +10,11 @@ "main": "lib/index.js", | ||
"fs-extra": "^0.30.0", | ||
"gulp": "^3.9.0", | ||
"gulp-util": "^3.0.7", | ||
"shelljs": "^0.7.0", | ||
"shelljs": "^0.7.4", | ||
"through2": "^2.0.1" | ||
}, | ||
"devDependencies": { | ||
"@ckeditor/ckeditor5-dev-lint": "^1.0.1", | ||
"chai": "^3.5.0", | ||
"@ckeditor/ckeditor5-dev-lint": "^1.0.1", | ||
"guppy-pre-commit": "^0.3.0", | ||
"gulp": "^3.9.1", | ||
"guppy-pre-commit": "^0.4.0", | ||
"istanbul": "^0.4.4", | ||
@@ -21,0 +21,0 @@ "mocha": "^3.0.2", |
@@ -479,3 +479,60 @@ /** | ||
} ); | ||
describe( 'copyFile', () => { | ||
const fs = require( 'fs-extra' ); | ||
it( 'rejects Promise when file does not exist', () => { | ||
const readFileStub = sandbox.stub( fs, 'readFile', ( from, to, callback ) => { | ||
callback( 'Some error during readFile.' ); | ||
} ); | ||
return tools.copyFile( '/tmp/not/existing/file.txt', '/tmp/file.txt' ) | ||
.catch( ( err ) => { | ||
expect( readFileStub.calledOnce ).to.equal( true ); | ||
expect( readFileStub.firstCall.args[ 0 ] ).to.equal( '/tmp/not/existing/file.txt' ); | ||
expect( err ).to.equal( 'Some error during readFile.' ); | ||
} ); | ||
} ); | ||
it( 'rejects Promise when file cannot be saved', () => { | ||
const readFileStub = sandbox.stub( fs, 'readFile', ( from, to, callback ) => { | ||
callback( null, 'Some data.' ); | ||
} ); | ||
const outputFileStub = sandbox.stub( fs, 'outputFile', ( to, data, callback ) => { | ||
callback( 'Some error during outputFile.' ); | ||
} ); | ||
return tools.copyFile( '/tmp/directory/file.txt', '/tmp/file.txt' ) | ||
.catch( ( err ) => { | ||
expect( readFileStub.calledOnce ).to.equal( true ); | ||
expect( readFileStub.firstCall.args[ 0 ] ).to.equal( '/tmp/directory/file.txt' ); | ||
expect( outputFileStub.calledOnce ).to.equal( true ); | ||
expect( outputFileStub.firstCall.args[ 0 ] ).to.equal( '/tmp/file.txt' ); | ||
expect( outputFileStub.firstCall.args[ 1 ] ).to.equal( 'Some data.' ); | ||
expect( err ).to.equal( 'Some error during outputFile.' ); | ||
} ); | ||
} ); | ||
it( 'resolves Promise when file was copied', () => { | ||
const readFileStub = sandbox.stub( fs, 'readFile', ( from, to, callback ) => { | ||
callback( null, 'Some data.' ); | ||
} ); | ||
const outputFileStub = sandbox.stub( fs, 'outputFile', ( to, data, callback ) => { | ||
callback( null ); | ||
} ); | ||
return tools.copyFile( '/tmp/directory/file.txt', '/tmp/file.txt' ) | ||
.then( () => { | ||
expect( readFileStub.calledOnce ).to.equal( true ); | ||
expect( readFileStub.firstCall.args[ 0 ] ).to.equal( '/tmp/directory/file.txt' ); | ||
expect( outputFileStub.calledOnce ).to.equal( true ); | ||
expect( outputFileStub.firstCall.args[ 0 ] ).to.equal( '/tmp/file.txt' ); | ||
expect( outputFileStub.firstCall.args[ 1 ] ).to.equal( 'Some data.' ); | ||
} ); | ||
} ); | ||
} ); | ||
} ); | ||
} ); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
66329
5
1565
8
30
- Removedgulp@^3.9.0
- Removedarchy@1.0.0(transitive)
- Removedarr-diff@4.0.0(transitive)
- Removedarr-flatten@1.1.0(transitive)
- Removedarr-union@3.1.0(transitive)
- Removedarray-each@1.0.1(transitive)
- Removedarray-slice@1.1.0(transitive)
- Removedarray-unique@0.3.2(transitive)
- Removedassign-symbols@1.0.0(transitive)
- Removedatob@2.1.2(transitive)
- Removedbase@0.11.2(transitive)
- Removedbraces@2.3.2(transitive)
- Removedcache-base@1.0.1(transitive)
- Removedclass-utils@0.3.6(transitive)
- Removedclone@0.2.0(transitive)
- Removedcollection-visit@1.0.0(transitive)
- Removedcomponent-emitter@1.3.1(transitive)
- Removedcopy-descriptor@0.1.1(transitive)
- Removeddebug@2.6.9(transitive)
- Removeddecode-uri-component@0.2.2(transitive)
- Removeddefaults@1.0.4(transitive)
- Removeddefine-property@0.2.51.0.02.0.2(transitive)
- Removeddeprecated@0.0.1(transitive)
- Removeddetect-file@1.0.0(transitive)
- Removedend-of-stream@0.1.5(transitive)
- Removedexpand-brackets@2.1.4(transitive)
- Removedexpand-tilde@2.0.2(transitive)
- Removedextend@3.0.2(transitive)
- Removedextend-shallow@2.0.13.0.2(transitive)
- Removedextglob@2.0.4(transitive)
- Removedfill-range@4.0.0(transitive)
- Removedfind-index@0.1.1(transitive)
- Removedfindup-sync@2.0.0(transitive)
- Removedfined@1.2.0(transitive)
- Removedfirst-chunk-stream@1.0.0(transitive)
- Removedflagged-respawn@1.0.1(transitive)
- Removedfor-in@1.0.2(transitive)
- Removedfor-own@1.0.0(transitive)
- Removedfragment-cache@0.2.1(transitive)
- Removedgaze@0.5.2(transitive)
- Removedget-value@2.0.6(transitive)
- Removedglob@3.1.214.5.3(transitive)
- Removedglob-stream@3.1.18(transitive)
- Removedglob-watcher@0.0.6(transitive)
- Removedglob2base@0.0.12(transitive)
- Removedglobal-modules@1.0.0(transitive)
- Removedglobal-prefix@1.0.2(transitive)
- Removedglobule@0.1.0(transitive)
- Removedgraceful-fs@1.2.33.0.12(transitive)
- Removedgulp@3.9.1(transitive)
- Removedhas-value@0.3.11.0.0(transitive)
- Removedhas-values@0.1.41.0.0(transitive)
- Removedhomedir-polyfill@1.0.3(transitive)
- Removedinherits@1.0.2(transitive)
- Removedini@1.3.8(transitive)
- Removedis-absolute@1.0.0(transitive)
- Removedis-accessor-descriptor@1.0.1(transitive)
- Removedis-buffer@1.1.6(transitive)
- Removedis-data-descriptor@1.0.1(transitive)
- Removedis-descriptor@0.1.71.0.3(transitive)
- Removedis-extendable@0.1.11.0.1(transitive)
- Removedis-extglob@2.1.1(transitive)
- Removedis-glob@3.1.0(transitive)
- Removedis-number@3.0.0(transitive)
- Removedis-plain-object@2.0.4(transitive)
- Removedis-relative@1.0.0(transitive)
- Removedis-unc-path@1.0.0(transitive)
- Removedis-utf8@0.2.1(transitive)
- Removedis-windows@1.0.2(transitive)
- Removedisexe@2.0.0(transitive)
- Removedisobject@2.1.03.0.1(transitive)
- Removedkind-of@3.2.24.0.06.0.3(transitive)
- Removedliftoff@2.5.0(transitive)
- Removedlodash@1.0.2(transitive)
- Removedlru-cache@2.7.3(transitive)
- Removedmake-iterator@1.0.1(transitive)
- Removedmap-cache@0.2.2(transitive)
- Removedmap-visit@1.0.0(transitive)
- Removedmicromatch@3.1.10(transitive)
- Removedminimatch@0.2.142.0.10(transitive)
- Removedmixin-deep@1.3.2(transitive)
- Removedmkdirp@0.5.6(transitive)
- Removedms@2.0.0(transitive)
- Removednanomatch@1.2.13(transitive)
- Removednatives@1.1.6(transitive)
- Removedobject-copy@0.1.0(transitive)
- Removedobject-visit@1.0.1(transitive)
- Removedobject.defaults@1.1.0(transitive)
- Removedobject.map@1.0.1(transitive)
- Removedobject.pick@1.3.0(transitive)
- Removedonce@1.3.3(transitive)
- Removedorchestrator@0.3.8(transitive)
- Removedordered-read-streams@0.1.0(transitive)
- Removedos-homedir@1.0.2(transitive)
- Removedparse-filepath@1.0.2(transitive)
- Removedparse-passwd@1.0.0(transitive)
- Removedpascalcase@0.1.1(transitive)
- Removedpath-root@0.1.1(transitive)
- Removedpath-root-regex@0.1.2(transitive)
- Removedposix-character-classes@0.1.1(transitive)
- Removedpretty-hrtime@1.0.3(transitive)
- Removedreadable-stream@1.0.34(transitive)
- Removedregex-not@1.0.2(transitive)
- Removedrepeat-element@1.1.4(transitive)
- Removedrepeat-string@1.6.1(transitive)
- Removedresolve-dir@1.0.1(transitive)
- Removedresolve-url@0.2.1(transitive)
- Removedret@0.1.15(transitive)
- Removedsafe-regex@1.1.0(transitive)
- Removedsemver@4.3.6(transitive)
- Removedsequencify@0.0.7(transitive)
- Removedset-value@2.0.1(transitive)
- Removedsigmund@1.0.1(transitive)
- Removedsnapdragon@0.8.2(transitive)
- Removedsnapdragon-node@2.1.1(transitive)
- Removedsnapdragon-util@3.0.1(transitive)
- Removedsource-map@0.5.7(transitive)
- Removedsource-map-resolve@0.5.3(transitive)
- Removedsource-map-url@0.4.1(transitive)
- Removedsplit-string@3.1.0(transitive)
- Removedstatic-extend@0.1.2(transitive)
- Removedstream-consume@0.1.1(transitive)
- Removedstrip-bom@1.0.0(transitive)
- Removedthrough2@0.6.5(transitive)
- Removedtildify@1.2.0(transitive)
- Removedto-object-path@0.3.0(transitive)
- Removedto-regex@3.0.2(transitive)
- Removedto-regex-range@2.1.1(transitive)
- Removedunc-path-regex@0.1.2(transitive)
- Removedunion-value@1.0.1(transitive)
- Removedunique-stream@1.0.0(transitive)
- Removedunset-value@1.0.0(transitive)
- Removedurix@0.1.0(transitive)
- Removeduse@3.1.1(transitive)
- Removeduser-home@1.1.1(transitive)
- Removedv8flags@2.1.1(transitive)
- Removedvinyl@0.4.6(transitive)
- Removedvinyl-fs@0.3.14(transitive)
- Removedwhich@1.3.1(transitive)
Updatedshelljs@^0.7.4