var Promise = require('es6-promise').Promise;
var TMP_DIR = 'build/tmp';
- function moveComments(code) {
- var comments = [], rest = [];
- code.split('\n').forEach(function (line) {
+ function moveComments(code, moveType) {
+ var comments = [], rest = [], skipId = -1;
+ code.split('\n').forEach(function (line, i) {
+ var isComment = false;
if (line.trim().slice(0, 3) === '//!') {
+ isComment = true;
+ }
+ if (isComment && moveType === 'main-only') {
+ if (i === skipId + 1 ||
+ line.trim() === '//! moment.js locale configuration') {
+ skipId = i;
+ // continue to next line
+ return;
+ }
+ }
+
+ if (isComment) {
comments.push(line.trim());
} else {
rest.push(line);
var umd = bundle.toUmd({name: umdName}),
fixed = header + umd.code.split('\n').slice(skipLines).join('\n');
if (opts.moveComments) {
- fixed = moveComments(fixed);
+ fixed = moveComments(fixed, opts.moveComments);
}
grunt.file.write(opts.target, fixed);
});
base: 'src',
code: code,
umdName: 'moment',
- target: target
+ target: target,
+ moveComments: 'main-only'
}).then(function () {
var code = grunt.file.read(target);
var getDefaultRegExp = new RegExp('var ([a-z$_]+) =\\s+{[^]\\s+get default \\(\\) { return ([a-z$_]+); }[^]\\s+}', '');