From db8fa15d3290a8ed50bd0939bd1778fb2a68141d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Krzto=C5=84?= Date: Mon, 23 Nov 2020 17:21:38 +0100 Subject: [PATCH] Change script to valid grunt task. --- core/ckeditor_base.js | 2 +- dev/tasks/ckeditor-base-replace.js | 39 +++++++++++++++++------------- package.json | 3 +-- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/core/ckeditor_base.js b/core/ckeditor_base.js index fdae5229b30..f7f50bef970 100644 --- a/core/ckeditor_base.js +++ b/core/ckeditor_base.js @@ -10,7 +10,7 @@ // #### Compressed Code // Compressed code in ckeditor.js must be be updated on changes in the script. -// Simply run `npm run build-base` after changing this file. +// Simply run `grunt ckeditor-base-replace` after changing this file. // #### Raw code // ATTENTION: read the above "Compressed Code" notes when changing this code. diff --git a/dev/tasks/ckeditor-base-replace.js b/dev/tasks/ckeditor-base-replace.js index d7cf32a8659..a7b75140350 100644 --- a/dev/tasks/ckeditor-base-replace.js +++ b/dev/tasks/ckeditor-base-replace.js @@ -7,26 +7,31 @@ /* jshint node: true, browser: false, es3: false, esversion: 6 */ 'use strict'; + const fs = require( 'fs' ); const uglify = require( 'uglify-js' ); const replace = require( 'replace-in-file' ); -const code = fs.readFileSync( './core/ckeditor_base.js', 'utf8' ); -const minified = uglify.minify( code, { - ie8: true -} ); +module.exports = function( grunt ) { + grunt.registerTask( 'ckeditor-base-replace', 'Inline core/ckeditor_base.js to into ckeditor.js.', function() { + const code = fs.readFileSync( './core/ckeditor_base.js', 'utf8' ); + const minified = uglify.minify( code, { + ie8: true + } ); -try { - const results = replace.sync( { - encoding: 'utf8', - files: './ckeditor.js', - from: /\/\/\s+replace_start\n(.|\n|\t|\r)*?\n\/\/\s+replace_end/, - to: `// replace_start\n${ minified.code }\n// replace_end` - } ); + try { + const results = replace.sync( { + encoding: 'utf8', + files: './ckeditor.js', + from: /\/\/\s+replace_start\n(.|\n|\t|\r)*?\n\/\/\s+replace_end/, + to: `// replace_start\n${ minified.code }\n// replace_end` + } ); - console.log( `Replacement successful:` ); - console.log( results ); -} -catch ( error ) { - console.error( `Replacement failed: ${ error }` ); -} + console.log( `Replacement successful:` ); + console.log( results ); + } + catch ( error ) { + console.error( `Replacement failed: ${ error }` ); + } + } ); +}; diff --git a/package.json b/package.json index 0a53b84e8cf..a79d4ac98ed 100644 --- a/package.json +++ b/package.json @@ -26,8 +26,7 @@ "uglify-js": "^3.12.0" }, "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", - "build-base": "node dev/tasks/ckeditor-base-replace.js" + "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [ "ckeditor4",