<commit_before>#!/usr/bin/node

const fs = require('fs');

const MusicPlayer = require('./modules/queue');
const Logger = require('./Core/Logger');
const RedisBrain = require('./Core/Brain/Redis');
const Types = require('./queue/types');

const oath = require('./hubot_oath.json');

const container = new Map();
container.set('commandManager', { add: function() {} });
container.set('logger', new Logger());
container.set('redisBrain', new RedisBrain());
const musicPlayer = new MusicPlayer(container);

const files = process.argv.slice(2);

//const flac = files.filter(file => file.endsWith('.flac'));
//console.log(flac);

//const promise = Promise.all(flac.map(url => {
const promise = Promise.all(files.map(url => {
  const info = {
    title: 'ffmpeg',
    format: 'ffmpeg',
    encoding: 'ffmpeg',
    url,
  };

  const record = {
    type: Types.LOCAL,
    ownerId: oath.mbilkerId,
    guildId: oath.mainGuildId,
    info,
  };

  return new Promise((resolve, reject) => {
    musicPlayer.queueSave(oath.mainGuildId, record, (err, res) => {
      if (err) {
        return reject(err);
      }
      return resolve(res);
    });
  });
}));

promise.then(() => {
  console.log('all done');

  container.get('redisBrain').quit();
}).catch((err) => {
  console.log(err);
});;
<commit_msg>force-queue: fix promise resolve logic<commit_after>#!/usr/bin/node

const fs = require('fs');
const path = require('path');

const MusicPlayer = require('./modules/queue');
const Logger = require('./Core/Logger');
const RedisBrain = require('./Core/Brain/Redis');
const Types = require('./queue/types');

const oath = require('./hubot_oath.json');

const container = new Map();
container.set('commandManager', { add: function() {} });
container.set('logger', new Logger());
container.set('redisBrain', new RedisBrain());
const musicPlayer = new MusicPlayer(container);

const files = process.argv.slice(2).map(url => path.resolve(url));

//const flac = files.filter(file => file.endsWith('.flac'));
//console.log(flac);

//const promise = Promise.all(flac.map(url => {
const promise = Promise.all(files.map(url => {
  const info = {
    title: 'ffmpeg',
    format: 'ffmpeg',
    encoding: 'ffmpeg',
    url,
  };

  const record = {
    type: Types.LOCAL,
    ownerId: oath.mbilkerId,
    guildId: oath.mainGuildId,
    info,
  };

  return new Promise((resolve, reject) => {
    musicPlayer.queueSave(oath.mainGuildId, record, (res) => {
      return resolve(res);
    });
  });
}));

console.log(promise);

promise.then(() => {
  console.log('all done');

  container.get('redisBrain').quit();
}).catch((err) => {
  console.log(err);
});

{'fraction_non_alphanumeric': 0.19620493358633775, 'fraction_numerical': 0.0007590132827324478, 'mean_word_length': 3.9363295880149813, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1821088', 'n_tokens_mistral': 893, 'n_tokens_neox': 876, 'n_words': 180}