Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch to esm #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@
`$ npm run clone-spectra-data`

### 5 - Now just run the the index script in the source folder and follow the instructions:
`$ node src/index`
`$ node src/index.js`

### 6 - In the results folder you will find a zip file, just dropped in drag and drop module and check the result.

## [View](https://my.cheminfo.org/?viewURL=https%3A%2F%2Fmydb.cheminfo.org%2Fdb%2Fvisualizer%2Fentry%2F111a2c7f7965d73c1eec6efaded0e739%2Fview.json)


23 changes: 14 additions & 9 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const fs = require('fs');
import fs from 'fs';

const DirectManager = require('direct-manager').default;
const direct = require('ml-direct');
const SD = require('./utils/spectra-data');
import DirectManager from 'direct-manager';
import direct from 'ml-direct';
import SD from './utils/spectra-data';

require('colors');
const { selectMolecule, pause, askIterations } = require('./utils/menu.js');
import 'colors';
import { selectMolecule, pause, askIterations } from './utils/menu.js';

console.clear();

Expand All @@ -19,9 +19,14 @@ const main = async () => {
await pause(molecule, parseInt(iterations));
} while (!options.molecule || !options.iterations);

const prediction = require(`../molecules/${options.molecule}/prediction.json`);
const settings = require(`../molecules/${options.molecule}/settings.json`);
const spectra = require(`../molecules/${options.molecule}/spectra.json`);
const promises = ['prediction', 'settings', 'spectra'].map(file =>
import(
`../molecules/${options.molecule}/${file}.json`,
{ assert: { type: 'json' } }
)
);

const [ prediction, settings, spectra ] = await Promise.all(promises);

const spectraProperties = {
frequency: 400,
Expand Down
6 changes: 3 additions & 3 deletions src/utils/menu.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const inquirer = require('inquirer');
require('colors');
import inquirer from 'inquirer';
import 'colors';

const menuOptions = [
{
Expand Down Expand Up @@ -89,4 +89,4 @@ const askIterations = async (message) => {
return iterations.trim();
};

module.exports = { selectMolecule, pause, askIterations };
export { selectMolecule, pause, askIterations };