From 0b6fc610e84e49beb923930ac6cef33e98e7d1fd Mon Sep 17 00:00:00 2001 From: PhilKunz Date: Wed, 5 Oct 2016 12:27:30 +0200 Subject: [PATCH] made cli.js path discovery smarter --- assets/cli.js | 2 +- dist/cli.js | 2 +- dist/npmts.assets.js | 6 +++++- ts/npmts.assets.ts | 12 +++++++----- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/assets/cli.js b/assets/cli.js index 9ab44a7..c9808e7 100644 --- a/assets/cli.js +++ b/assets/cli.js @@ -1,2 +1,2 @@ #!/usr/bin/env node -var index = require("./index.js"); \ No newline at end of file +var index = require("../{{pathToIndex}}"); \ No newline at end of file diff --git a/dist/cli.js b/dist/cli.js index 9ab44a7..c9808e7 100644 --- a/dist/cli.js +++ b/dist/cli.js @@ -1,2 +1,2 @@ #!/usr/bin/env node -var index = require("./index.js"); \ No newline at end of file +var index = require("../{{pathToIndex}}"); \ No newline at end of file diff --git a/dist/npmts.assets.js b/dist/npmts.assets.js index 41990e3..0d681e4 100644 --- a/dist/npmts.assets.js +++ b/dist/npmts.assets.js @@ -3,12 +3,16 @@ const plugins = require("./npmts.plugins"); const paths = require("./npmts.paths"); const q = require("q"); const npmts_promisechain_1 = require("./npmts.promisechain"); +const npmts_check_1 = require("./npmts.check"); exports.run = function (configArg) { let done = q.defer(); let config = configArg; npmts_promisechain_1.npmtsOra.text('now looking at ' + 'required assets'.yellow); if (config.cli === true) { - plugins.smartfile.fs.copySync(plugins.path.join(paths.npmtsAssetsDir, 'cli.js'), plugins.path.join(paths.distDir, 'cli.js')); + let mainJsPath = npmts_check_1.projectInfo.packageJson.main; + let cliJsString = plugins.smartfile.fs.toStringSync(plugins.path.join(paths.npmtsAssetsDir, 'cli.js')); + cliJsString = cliJsString.replace('{{pathToIndex}}', mainJsPath); + plugins.smartfile.memory.toFsSync(cliJsString, plugins.path.join(paths.distDir, 'cli.js')); plugins.beautylog.ok('installed CLI assets!'); done.resolve(config); } diff --git a/ts/npmts.assets.ts b/ts/npmts.assets.ts index 0343194..d154bd7 100644 --- a/ts/npmts.assets.ts +++ b/ts/npmts.assets.ts @@ -2,17 +2,19 @@ import plugins = require('./npmts.plugins') import paths = require('./npmts.paths') import * as q from 'q' -import {npmtsOra} from './npmts.promisechain' + +import { npmtsOra } from './npmts.promisechain' +import { projectInfo } from './npmts.check' export var run = function(configArg){ let done = q.defer() let config = configArg npmtsOra.text('now looking at ' + 'required assets'.yellow) if (config.cli === true) { - plugins.smartfile.fs.copySync( - plugins.path.join(paths.npmtsAssetsDir,'cli.js'), - plugins.path.join(paths.distDir,'cli.js') - ) + let mainJsPath = projectInfo.packageJson.main + let cliJsString: string = plugins.smartfile.fs.toStringSync(plugins.path.join(paths.npmtsAssetsDir,'cli.js')) + cliJsString = cliJsString.replace('{{pathToIndex}}',mainJsPath) + plugins.smartfile.memory.toFsSync(cliJsString, plugins.path.join(paths.distDir,'cli.js')) plugins.beautylog.ok('installed CLI assets!') done.resolve(config) } else {