Skip to content

Commit

Permalink
Merge branch 't/11167'
Browse files Browse the repository at this point in the history
  • Loading branch information
oleq committed Nov 15, 2013
2 parents 647adc6 + bc251da commit 615d1e1
Show file tree
Hide file tree
Showing 81 changed files with 218 additions and 8,463 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
dev/iconmaker/node_modules
89 changes: 0 additions & 89 deletions dev/iconmaker/bin/iconmaker.js

This file was deleted.

89 changes: 89 additions & 0 deletions dev/iconmaker/iconmaker.js
@@ -0,0 +1,89 @@
#!/usr/bin/env node

/**
* @license Copyright (c) 2003-2013, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or http://ckeditor.com/license
*/

'use strict';

var path = require( 'path' ),
fs = require( 'fs' ),
argv = require( 'optimist' ).argv,
util = require( 'util' ),
exec = require( 'child_process' ).exec,

// The heart of the application.
main = require( './lib/main' ),
iconmaker = main.iconmaker,

// This is the size of the icon that makes it default, placed in directory/icon.png
// Other sizes are stored under directory/size/icon.png
DEFAULT_SIZE = main.DEFAULT_SIZE,

helpString = util.format( [
'Usage: iconmaker (options) [extra options]\n\n',

'\tThis program slices CKEditor iconsets into individual icons placed in various locations.\n\n',
'\tIconmaker depends on:\n',
'\t\t * Node.js (see: http://nodejs.org/)\n',
'\t\t * ImageMagick\'s command-line tool named convert (see: http://www.imagemagick.org/script/convert.php).\n\n',

'\tSample call (cold run first):\n\n',
'\t\t./dev/iconmaker/iconmaker.js -i skins/moono/dev/icons16.png -l skins/moono/dev/locations.json -c\n\n',

'Options:\n\n',

' -i FILE input PNG file with the iconset\n',
' -l FILE icon location JSON file\n',

'\nExtra options:\n\n',

' -s icon size (%s is default)\n',
' -c cold run (no file is touched)\n',
' -h this message\n'
].join( '' ), DEFAULT_SIZE );

function gracefulFailure( error ) {
console.error( '[!] %s', error.stack ? error.stack : error );
console.error( '[i] Bye bye!' );
process.exit( 1 );
}

// Display help on demand.
if ( argv.h ) {
console.log( helpString );
process.exit( 0 );
}

// Display help if mandatory arguments are missing.
else if ( !( argv.i && argv.l ) ) {
console.log( helpString );
process.exit( 1 );
}

// Check if convert is installed.
exec( 'convert -version', function( error, stdout, stderr ) {
if ( error ) {
gracefulFailure( 'Convert not found in PATH. See http://www.imagemagick.org/ for more help.' );
}
} );

// Check if PNG exist.
try {
fs.statSync( argv.i );
} catch ( error ) {
gracefulFailure( error );
}

// Load locations file.
fs.readFile( argv.l, function( error, locations ) {
if ( error )
gracefulFailure( error );

try {
iconmaker( argv.i, JSON.parse( locations ), argv.s || DEFAULT_SIZE, argv.c );
} catch ( e ) {
gracefulFailure( e );
}
} );

0 comments on commit 615d1e1

Please sign in to comment.