Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into feat/add-proper-log…
Browse files Browse the repository at this point in the history
…ging
  • Loading branch information
HaidarJbeily7 committed Nov 9, 2024
2 parents ff9fe49 + 5ca37e4 commit 6b3c662
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
11 changes: 11 additions & 0 deletions eo2js/src/commands/link.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@ const link = function(options) {
execSync('npm install', {cwd: project})

console.log(`Copying ${main} file...`)
const lock = path.resolve(project, 'package-lock.json')
if (!fs.existsSync(lock)) {
execSync('npm install', {cwd: project})
if (options.dependency) {
fs.cpSync(
options.dependency,
path.resolve(project, 'node_modules/eo2js-runtime'),
{recursive: true}
)
}
}
fs.copyFileSync(
path.resolve(options.resources, `js/${main}`),
path.resolve(project, main)
Expand Down
11 changes: 11 additions & 0 deletions eo2js/test/commands/link.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const {runSync, assertFilesExist} = require('../helpers')
const path = require('path');
const fs = require('fs');
const assert = require('assert');

describe('link', function() {
const home = path.resolve('temp/test-link')
Expand Down Expand Up @@ -39,4 +40,14 @@ describe('link', function() {
assertFilesExist(link('--tests'), project, ['node_modules/mocha'])
done()
})
it('should not reinstall npm packages if package-lock.json exists', function(done) {
this.timeout(10000)
link()
const lockFilePath = path.resolve(project, 'package-lock.json')
const initialMtime = fs.statSync(lockFilePath).mtime
link()
const finalMtime = fs.statSync(lockFilePath).mtime
assert.strictEqual(initialMtime.getTime(), finalMtime.getTime(), 'package-lock.json was modified on second run')
done()
})
})

0 comments on commit 6b3c662

Please sign in to comment.