diff --git a/.travis.yml b/.travis.yml index f1c06d5..a26b2c8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,30 @@ language: node_js -node_js: - - "node" -after_script: - - npm run coveralls +node_js: 14 -deploy: - provider: script - skip_cleanup: true - script: - - yarn semantic-release - on: - branch: master +jobs: + include: + - &test + stage: test + os: linux + install: yarn + script: yarn test + after_script: npm run coveralls + workspaces: + create: + name: shared + paths: + - node_modules + + - <<: *test + os: windows + env: YARN_GPG=no + script: cli/synp.js -s yarn.lock + after_script: skip + workspaces: + + - stage: release + if: branch = master AND type != pull_request + workspaces: + use: shared + install: skip + script: yarn release diff --git a/lib/lockfileV1/tree.js b/lib/lockfileV1/tree.js index 03b4429..245e925 100644 --- a/lib/lockfileV1/tree.js +++ b/lib/lockfileV1/tree.js @@ -1,6 +1,7 @@ 'use strict' const { sep, resolve } = require('path') +const { has } = require('lodash') const sortObject = require('sort-object-keys') const { dependenciesForYarn } = require('./dependencies') const { yarnEntry, npmEntry } = require('./entry') @@ -44,7 +45,7 @@ module.exports = { return formattedTree }, buildNpmTree (nodeModulesTree, yarnObject, workspacesTree) { - const countDepth = (path) => (path.match(new RegExp(`${sep}node_modules${sep}`, 'g')) || []).length + const countDepth = (path) => path.split(`${sep}node_modules${sep}`).length - 1 const sortedNodeModules = Object.keys(nodeModulesTree).sort((a, b) => countDepth(a) < countDepth(b) ? -1 : 1) const basePath = sortedNodeModules[0].split(sep) @@ -63,7 +64,7 @@ module.exports = { entry.requires = sortObject(dependencies) } - if ((nodeModulesTree[parentPackagePath(mPath)].devDependencies || {})[name]) { + if (has(nodeModulesTree[parentPackagePath(mPath)], `devDependencies.${name}`)) { entry.dev = true } diff --git a/package.json b/package.json index 2fd9560..ef392a5 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "scripts": { "test": "standard && npm run test:unit", "test:unit": "tape ./test/*.spec.js", + "test:integration": "cli/synp.js -s yarn.lock", "coverage": "nyc --reporter=lcov npm test", "coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls" },