Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ckeditor/ckeditor5-dev-utils

Package Overview
Dependencies
Maintainers
1
Versions
261
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ckeditor/ckeditor5-dev-utils - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

30

lib/tools.js

@@ -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 {

10

package.json
{
"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.' );
} );
} );
} );
} );
} );
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc